nvpunk-config/init.lua

195 lines
6.8 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', 'gu', ':Gitsigns reset_hunk<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', '<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 })
vim.api.nvim_set_keymap('n', ',t', ':tab drop<Space>', { noremap = true })
vim.api.nvim_set_keymap('v', ',t', ':tab drop<Space>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>q', ':tabclose<CR>', { noremap = true })
vim.cmd [[
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
]]
vim.cmd [[
let g:rooter_manual_only = 0
let g:rooter_silent_chdir = 1
let g:rooter_patterns = ['.git']
let g:rooter_change_directory_for_non_project_files = 'current'
]]
require('mason-tool-installer').setup {
-- a list of all tools you want to ensure are installed upon start
ensure_installed = {
'bash-language-server',
'clangd',
'codelldb',
'cpptools',
'debugpy',
'emmet-ls',
'html-lsp',
'jq',
'json-lsp',
'lua-language-server',
'luau-lsp',
'node-debug2-adapter',
'pyright',
'rust-analyzer',
'shellcheck',
'shellharden',
'shfmt',
'vim-language-server',
},
-- if set to true this will check each tool for updates. If updates
-- are available the tool will be updated. This setting does not
-- affect :MasonToolsUpdate or :MasonToolsInstall.
-- Default: false
auto_update = false,
-- automatically install / update on startup. If set to false nothing
-- will happen on startup. You can use :MasonToolsInstall or
-- :MasonToolsUpdate to install tools and check for updates.
-- Default: true
run_on_start = true,
-- set a delay (in ms) before the installation starts. This is only
-- effective if run_on_start is set to true.
-- e.g.: 5000 = 5 second delay, 10000 = 10 second delay, etc...
-- Default: 0
start_delay = 3000, -- 3 second delay
-- Only attempt to install if 'debounce_hours' number of hours has
-- elapsed since the last time Neovim was started. This stores a
-- timestamp in a file named stdpath('data')/mason-tool-installer-debounce.
-- This is only relevant when you are using 'run_on_start'. It has no
-- effect when running manually via ':MasonToolsInstall' etc....
-- Default: nil
debounce_hours = 5, -- at least 5 hours between attempts to install/update
}
-- vim.opt.shada = "/100,'10,\"100,:20,%"
-- vim.opt.shadafile = "/home/pfs/.config/nvpunk/lua/user/nviminfo"
-- autocmd BufWinLeave * if expand("%") != "" | silent! mkview | endif
-- autocmd BufWinEnter * if expand("%") != "" | silent! loadview | endif
--map <C-\> <plug>NERDCommenterToggle
--map <C-A-\> <plug>NERDCommenterSexy
--nnoremap <leader>s :CocFzfList snippets<CR>