-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db96451
commit 33d5b4e
Showing
5 changed files
with
156 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
|
||
TemplatePath = "${HOME}/.config/nvim/language_specific/templates/" | ||
MaxLinesCMP = 5000 | ||
local va = vim.api; | ||
local vauto = vim.api.nvim_create_autocmd; | ||
local vc = vim.cmd; | ||
|
||
--------------------------------- | ||
-- Disable CMP For Large Files -- | ||
--------------------------------- | ||
vauto({"BufEnter", "BufWinEnter"}, { | ||
pattern = {"*"}, | ||
callback = function(args) | ||
if va.nvim_buf_line_count(args.buf) > MaxLinesCMP then | ||
require('cmp').setup.buffer( { enabled = false } ) | ||
end | ||
end}) | ||
vauto({"FocusGained", "CursorHold", "CursorHoldI"}, { | ||
pattern = { "*" }, | ||
callback = function() | ||
vc("silent! checktime") | ||
end}) | ||
------------------------- | ||
-- BufNewFile, BufRead -- | ||
------------------------- | ||
local function bufnew_bufread(glob, comms) | ||
vauto({"BufNewFile", "BufRead"}, { | ||
pattern = glob, | ||
callback = function() | ||
for _,com in ipairs(comms) do | ||
vc(com) | ||
end | ||
end}) | ||
end | ||
local function bufnr_add(globcomms) | ||
for glob,comms in pairs(globcomms) do | ||
bufnew_bufread(glob, comms) | ||
end | ||
end | ||
------------------------- | ||
-- Templates ------------ | ||
------------------------- | ||
local function template_add(glob, template_path) | ||
vauto({"BufNewFile"}, { | ||
pattern = glob, | ||
callback = function() | ||
local full_path = TemplatePath .. template_path | ||
vc("0read " .. full_path) | ||
vc("silent w") | ||
vc("silent !chmod 700 %") | ||
end}) | ||
end | ||
local function template_add_e(exts) | ||
for _,ext in ipairs(exts) do | ||
template_add("*." .. ext, "template." .. ext) | ||
end | ||
end | ||
------------------------- | ||
-- Vars ----------------- | ||
------------------------- | ||
local exts = { "sh", "py", "kalker", "exs", "tex", "ex", "html", "cpp" } | ||
local globcomms = { | ||
["${HOME}/.bashrc"] = { | ||
"setfiletype bash", | ||
"source ${HOME}/.config/nvim/language_specific/bashrc.vim" | ||
}, | ||
["${HOME}/bashrc_files/*" ] = { "setfiletype bash" }, | ||
["*.sh" ] = { "setfiletype bash" }, | ||
["${HOME}/.config/polybar/*.ini" ] = { "setfiletype dosini" }, | ||
["${HOME}/.config/polybar/*/*.ini" ] = { "setfiletype dosini" }, | ||
["*.kalker" ] = { "setfiletype kalker" }, | ||
["${HOME}/.config/i3/*" ] = { "setfiletype i3" }, | ||
["*.ex,*.exs" ] = { "setfiletype elixir" }, | ||
["*.schema" ] = { "setfiletype sql" }, | ||
["*.md" ] = { "setfiletype markdown" }, | ||
|
||
["${HOME}/.config/zathura/*"] = { "set syntax=zathurarc" }, | ||
|
||
} | ||
template_add_e(exts) | ||
bufnr_add(globcomms) | ||
|
||
------------------------- | ||
-- VimLeave ------------- | ||
------------------------- | ||
vauto({"VimLeave"}, { | ||
pattern = "*", | ||
callback = function() | ||
ClipBoardExit() | ||
end | ||
}) | ||
|
||
------------------------- | ||
-- TermOpen ------------- | ||
------------------------- | ||
vauto({"TermOpen"}, { | ||
pattern = "*", | ||
callback = function() | ||
vc("setlocal statusline=%{b:term_title}") | ||
end | ||
}) | ||
|
||
------------------------- | ||
-- FileType Formatting -- | ||
------------------------- | ||
vauto({"FileType"}, { | ||
pattern = "*", | ||
callback = function() | ||
vc("setlocal formatoptions-=c formatoptions-=r formatoptions-=o") | ||
end | ||
}) | ||
|
||
------------------------- | ||
-- Help File ------------ | ||
------------------------- | ||
|
||
local pattern_a = "'\\l{2,}'" | ||
local pattern_b = "[|]\\zs\\S+\\ze[|]" | ||
local combined = pattern_a .. "|" .. pattern_b | ||
local bindings_help_buffer={ | ||
[ "CR" ] = "<C-]>", | ||
[ "BS" ] = "<C-T>", | ||
[ "o" ] = "/\\v(" .. combined .. ")<CR>", | ||
[ "O" ] = "?\\v(" .. combined .. ")<CR>", | ||
[ "<CR>" ] = "<C-]>", | ||
[ "<BS>" ] = "<C-T>", | ||
} | ||
|
||
vauto({"FileType"}, { | ||
pattern = "help", | ||
callback = function() | ||
for key,bind in pairs(bindings_help_buffer) do | ||
vim.keymap.set( "n", key, bind, { remap = false, buffer = true } ) | ||
end | ||
end | ||
}) | ||
|
||
-- autocmd FileType help nnoremap <buffer> <CR> <C-]> | ||
-- autocmd FileType help nnoremap <buffer> <BS> <C-T> | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
-- local nvim_rocks = require('nvim_rocks') | ||
-- nvim_rocks.install('fun') | ||
|
||
function DisableSlow() | ||
require('cmp').setup.buffer( { enabled = false } ) | ||
local va = vim.api; | ||
local vauto = vim.api.nvim_create_autocmd; | ||
local vc = vim.cmd; | ||
function ClipBoardExit() | ||
if va.executable("xclip") then | ||
va.system('xclip -selection clipboard -i -r <<< ', va.getreg('a')) | ||
end | ||
end | ||
|
||
function CheckSize(args) | ||
if vim.api.nvim_buf_line_count(args.buf) > 5000 then | ||
DisableSlow() | ||
end | ||
end | ||
|
||
|
||
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { | ||
pattern = {"*"}, | ||
callback = CheckSize | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters