mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
autopairs + cleanup
This commit is contained in:
parent
4b7636090f
commit
d01db43a23
15 changed files with 176 additions and 204 deletions
|
|
@ -1,7 +1,6 @@
|
|||
-- create undopath
|
||||
local undopath = vim.fn.stdpath('data') .. 'undo'
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
command = 'silent !mkdir -p ' .. undopath,
|
||||
command = 'silent !mkdir -p ' .. vim.fn.stdpath('data') .. 'undo',
|
||||
group = vim.api.nvim_create_augroup('Init', {}),
|
||||
})
|
||||
|
||||
|
|
@ -55,3 +54,57 @@ vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Init treesitter
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
callback = function(event)
|
||||
local bufnr = event.buf
|
||||
local filetype = vim.api.nvim_get_option_value('filetype', { buf = bufnr })
|
||||
|
||||
if filetype == '' then
|
||||
return
|
||||
end
|
||||
|
||||
local parser_name = vim.treesitter.language.get_lang(filetype)
|
||||
if not parser_name then
|
||||
return
|
||||
end
|
||||
local parser_installed = pcall(vim.treesitter.get_parser, bufnr, parser_name)
|
||||
if not parser_installed then
|
||||
return
|
||||
end
|
||||
|
||||
local function map(lhs, rhs, opts)
|
||||
if lhs == '' then
|
||||
return
|
||||
end
|
||||
opts = vim.tbl_deep_extend('force', { silent = true }, opts or {})
|
||||
vim.keymap.set({ 'v', 'n' }, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
vim.treesitter.start()
|
||||
|
||||
map('[c', function()
|
||||
require('treesitter-context').go_to_context(vim.v.count1)
|
||||
end, { desc = 'jump to TS context' })
|
||||
map(']f', function()
|
||||
require('nvim-treesitter-textobjects.move').goto_next_start('@function.outer', 'textobjects')
|
||||
end, { desc = 'next function def' })
|
||||
map('[f', function()
|
||||
require('nvim-treesitter-textobjects.move').goto_previous_start('@function.outer', 'textobjects')
|
||||
end, { desc = 'prev function def' })
|
||||
map(']a', function()
|
||||
require('nvim-treesitter-textobjects.move').goto_next_start('@parameter.inner', 'textobjects')
|
||||
end, { desc = 'next param def' })
|
||||
map('[a', function()
|
||||
require('nvim-treesitter-textobjects.move').goto_previous_start('@parameter.inner', 'textobjects')
|
||||
end, { desc = 'prev param def' })
|
||||
map('a]', function()
|
||||
require('nvim-treesitter-textobjects.swap').swap_next('@parameter.inner')
|
||||
end, { desc = 'swap next arg' })
|
||||
map('a[', function()
|
||||
require('nvim-treesitter-textobjects.swap').swap_previous('@parameter.inner')
|
||||
end, { desc = 'swap prev arg' })
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
vim.opt.autowrite = true
|
||||
vim.opt.backspace = 'indent,eol,start'
|
||||
vim.opt.confirm = true
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.diffopt = 'internal,filler,closeoff,inline:char'
|
||||
vim.opt.expandtab = true -- insert tabs as spaces
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.opt.inccommand = 'split' -- incremental live completion
|
||||
vim.opt.list = true
|
||||
vim.opt.laststatus = 1 -- statusline only if split
|
||||
vim.opt.nrformats:append('alpha') -- let Ctrl-a do letters as well
|
||||
vim.opt.path:append('**') -- enable fuzzy :find ing
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.shadafile = 'NONE' -- disable shada
|
||||
vim.opt.shadafile = 'NONE' -- disable shada (unless session)
|
||||
vim.opt.shiftwidth = 0 -- >> shifts by tabstop
|
||||
vim.opt.showmatch = true -- highlight matching brackets
|
||||
vim.opt.showmode = true
|
||||
vim.opt.signcolumn = 'no'
|
||||
vim.opt.softtabstop = -1 -- backspace removes tabstop
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.tabstop = 2 -- 2 space tabs are based
|
||||
vim.opt.updatetime = 250 -- decrease update time
|
||||
vim.opt.virtualedit = 'onemore'
|
||||
vim.opt.winborder = 'single'
|
||||
vim.opt.winborder = 'rounded'
|
||||
vim.cmd('colorscheme iofq')
|
||||
|
||||
-- Configure Neovim diagnostic messages
|
||||
|
|
@ -33,3 +32,5 @@ vim.diagnostic.config {
|
|||
source = 'if_many',
|
||||
},
|
||||
}
|
||||
require('config.keymaps')
|
||||
require('config.autocmd')
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ vim.keymap.set('n', '\\t', function()
|
|||
vim.o.tabstop = vim.o.tabstop == 8 and 2 or 2 * vim.o.tabstop
|
||||
end, { silent = true, desc = 'toggle tabstop' })
|
||||
vim.keymap.set({ 'v', 'i' }, 'wq', '<esc>l', { noremap = true, silent = true })
|
||||
vim.keymap.set({ 'v', 'n' }, 'q:', '<nop>')
|
||||
vim.keymap.set('v', '<', '<gv')
|
||||
vim.keymap.set('v', '>', '>gv')
|
||||
vim.keymap.set('n', 'n', 'nzz', { noremap = true })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue