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