nix/prog/nvim: improve lua augroups

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-19 09:56:00 +03:00
parent 4c39a7f30f
commit ce3ee731b3
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215

View file

@ -101,46 +101,48 @@ local bufReadFile = {'BufNewFile', 'BufRead'}
-- Set up a line limiter for each lang
local line_limiter_augroup = vim.api.nvim_create_augroup('line_limiter', {})
local function set_line_limiter(pattern, limit)
local function set_line_limiter(limit, patterns)
vim.api.nvim_create_autocmd(bufReadFile, {
pattern = pattern,
pattern = patterns,
group = line_limiter_augroup,
callback = function () vim.wo.colorcolumn = limit end,
callback = function () vim.wo.colorcolumn = tostring(limit) end,
})
end
set_line_limiter('*.nix', '101')
set_line_limiter('*.vim', '101')
set_line_limiter('*.lua', '101')
set_line_limiter('*.ts,*.tsx', '101')
set_line_limiter('*.js.*.jsx', '101')
set_line_limiter('*.rs', '101')
set_line_limiter('*.json', '81')
set_line_limiter('*.yml','*.yaml', '81')
set_line_limiter('*.md', '81')
set_line_limiter('*.html', '81')
set_line_limiter('*.css', '81')
-- TODO: add line limiter for haskell
set_line_limiter(101, {
'*.nix',
'*.vim',
'*.lua',
'*.ts',
'*.tsx',
'*.js',
'*.jsx',
'*.rs',
})
set_line_limiter(81, {
'*.json',
'*.yml',
'*.yaml',
'*.md',
'*.html',
'*.css',
})
-- Spell check for markdown files
local spell_check_augroup = vim.api.nvim_create_augroup('spell_check', {})
local function enable_spell_check(pattern)
vim.api.nvim_create_autocmd(bufReadFile, {
pattern = pattern,
vim.api.nvim_create_autocmd(bufReadFile, {
pattern = { '*.md' },
group = spell_check_augroup,
callback = function () vim.wo.spell = true end,
})
end
enable_spell_check '*.md'
})
-------------------------------------------------------------------------------
--
-- Bindings
--
local function disable_search_highlighting() vim.opt.hlsearch = false end
vim.keymap.set('n', '<C-z>', disable_search_highlighting, { desc = 'Clear search highlighting' })
local function clear_search_hl() vim.opt.hlsearch = false end
vim.keymap.set('n', '<C-z>', clear_search_hl, { desc = 'Clear search highlighting' })
-- Enable fast navigation between windows
vim.keymap.set('n', '<C-h>', '<C-W>h')