nvpunk-config/init.lua

126 lines
4.6 KiB
Lua

vim.opt.colorcolumn = '100'
vim.opt.undodir = '/home/pfs/.config/nvpunk/undo'
vim.opt.undofile = true
vim.opt.undolevels = 1000000000
vim.opt.history = 2000
vim.opt.clipboard = 'unnamed,unnamedplus'
vim.opt.foldenable = false
vim.opt.modeline = true
vim.opt.modelines = 3
vim.opt.scrolloff = 10
vim.opt.belloff = 'all'
vim.opt.errorbells = false
vim.opt.visualbell = false
vim.cmd [[nnoremap / /\v]]
vim.cmd [[vnoremap / /\v]]
-- vim.cmd [[nnoremap ? ?\v]]
-- vim.cmd [[vnoremap ? ?\v]]
vim.api.nvim_set_keymap('n', 'gi', ':FzfLua lsp_implementations<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', 'gr', ':FzfLua lsp_references<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', 'gF', ':lua vim.lsp.buf.format()<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>d', ':FzfLua diagnostics_document<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ']g', ':Gitsigns next_hunk<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '[g', ':Gitsigns prev_hunk<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', 'gs', ':Gitsigns preview_hunk_inline<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>DD', ':DiffviewOpen<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>DF', ':DiffviewFileHistory<CR>', { noremap = true })
vim.keymap.set('n', ']e', function()
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
end, { desc = 'Go to next LSP diagnostic error' })
vim.keymap.set('n', '[e', function()
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })
end, { desc = 'Go to previous LSP diagnostic error' })
vim.keymap.set('n', '<F2>', function()
vim.lsp.buf.rename()
end, { desc = 'LSP Rename symbol under cursor' })
-- Format on save for Rust
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("RustAutoFmt", { clear = true }),
pattern = { "*.rs" },
callback = function()
vim.lsp.buf.format({ async = false })
end,
})
require('fzf-lua').setup {
lsp = {
includeDeclaration = false
}
}
vim.api.nvim_set_keymap('n', '<leader><leader>', ':silent noh <CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>t', ':tab drop<Space>', { noremap = true })
vim.api.nvim_set_keymap('v', '<leader>t', ':tab drop<Space>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>q', ':tabclose<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-l>', 'gt', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-h>', 'gT', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-c>', '"+y', { noremap = true })
vim.api.nvim_set_keymap('v', '<C-c>', '"+yy', { noremap = true })
vim.api.nvim_set_keymap('n', '<C-x>', ':q<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',f', ':FzfLua files<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',F', ':FzfLua files query=<C-r><C-w><CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>h', ':tabedit % | ClangdSwitchSourceHeader<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>H', '/⚡<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>g', ':Git blame -w<CR>', { noremap = true })
-- blines
vim.api.nvim_set_keymap('n', '<leader>l', ':FzfLua grep_curbuf<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>L', ':FzfLua grep_curbuf query=<C-r><C-w><CR>', { noremap = true })
-- ripgrep
vim.api.nvim_set_keymap('n', '<leader>r', ':FzfLua live_grep_resume<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',r', ':FzfLua grep_cword<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',R', ':FzfLua grep_cWORD<CR>', { noremap = true })
-- symbols
vim.api.nvim_set_keymap('n', '<leader>s', ':FzfLua lsp_document_symbols<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',M', ':FzfLua lsp_live_workspace_symbols<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', ',n', ':silent exec "!ctc"<bar>redraw!<CR>', { noremap = true })
-- buffers
vim.api.nvim_set_keymap('n', '<leader>a', ':FzfLua buffers<CR>', { noremap = true })
-- search presets
vim.api.nvim_set_keymap('n', ',/', '/\\v<TODO>|<WORK>|<OPEN>|<WAIT><CR>', { noremap = true })
-- convenience shortcuts
vim.api.nvim_set_keymap('n', '<C-s>', '<Esc><Esc><Esc>:w<CR>', { noremap = true })
vim.api.nvim_set_keymap('v', '<C-s>', '<Esc><Esc><Esc>:w<CR>', { noremap = true })
vim.api.nvim_set_keymap('i', '<C-s>', '<Esc><Esc><Esc>:w<CR>', { noremap = true })
-- tabs
vim.api.nvim_set_keymap('n', ',,', ':tabe<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>.', ':tab drop %:p:h<CR>', { noremap = true })
--map <C-\> <plug>NERDCommenterToggle
--map <C-A-\> <plug>NERDCommenterSexy
--nnoremap <leader>s :CocFzfList snippets<CR>