Update config for "quality-of-life" changes

Comments in init.lua.

(<leader> is backspace usually.)

Disable "q" mappings, set "<leader>q" to use quick-comment.
Set "<leader>f" to use treesitter-fold.
Set "<leader>l" to load lsp-plugins.
This commit is contained in:
Stephen Seo 2024-02-21 14:16:29 +09:00
parent 098fc69960
commit 691b776858
3 changed files with 21 additions and 9 deletions

View file

@ -16,9 +16,11 @@ This is just a dump of my NVim config.
## Enabling LSP
In NeoVim, invoke `:call loadlsp#loadlspall()`, then reload the current open
files with `:e` and LSP functionality will be enabled for the currently open
files.
In NeoVim, ~~invoke `:call loadlsp#loadlspall()`, then reload the current open
files with `:e`~~ use the "<leader>l" (backslash and l) shortcut and LSP
functionality will be enabled for the currently open file. If you have more
than one buffer open, you may have to reopen them (with :e) for lsp plugins to
take effect.
`loadlsp#loadlspall()` is a custom function that can be found
[here](https://git.seodisparate.com/stephenseo/MyNeoVimConfig/src/branch/main/pack/packages/start/loadlsp/autoload/loadlsp.vim).

View file

@ -62,7 +62,7 @@ vim.api.nvim_command('autocmd InsertEnter * match ForbiddenWhitespace /\\t\\|\\s
vim.api.nvim_command('hi! CustomRedHighlight ctermbg=red guibg=red')
vim.api.nvim_command('match CustomRedHighlight /TODO/')
-- On <leader>i, open zenity textbox for gui text input
vim.cmd(
[[
" CJK input
@ -75,11 +75,13 @@ endfunction
nmap <silent> <leader>i :call CJKInput()<CR>
]])
--vim.cmd('nmap q :echo "I accidentally hit q, I don\'t use macros"<CR>')
--vim.cmd('vmap q <ESC>:echo "I accidentally hit q, I don\'t use macros"<CR>')
-- Disable q
vim.cmd('nmap q :echo "I accidentally hit q, I don\'t use macros"<CR>')
vim.cmd('vmap q <ESC>:echo "I accidentally hit q, I don\'t use macros"<CR>')
vim.cmd('nmap q :lua vim.g.quickcomment_togglecommentline()<CR>')
vim.cmd('vmap q :luado vim.g.quickcomment_togglecommentline(linenr)<CR>')
-- Set <leader>q to comment selected line(s)
vim.cmd('nmap <leader>q :lua vim.g.quickcomment_togglecommentline()<CR>')
vim.cmd('vmap <leader>q :luado vim.g.quickcomment_togglecommentline(linenr)<CR>')
vim.g.quickcomment_whitespaceprefix = 1
@ -95,7 +97,14 @@ require'nvim-treesitter.configs'.setup {
},
}
-- Setup folding based on treesitter
vim.g.foldmethod_treesitter_fn = function ()
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
end
-- <leader>f to treesitter-fold
vim.cmd('nmap <leader>f :lua vim.g.foldmethod_treesitter_fn()<CR>')
-- <leader>l to load lsp
vim.cmd('nmap <silent> <leader>l :call loadlsp#loadlspall()<CR> :e<CR> :echo "Loaded lsp plugins"<CR>')

View file

@ -133,10 +133,11 @@ lspconfig.jedi_language_server.setup{
}
-- apply available fix
vim.api.nvim_set_keymap("n", "<C-F>", "<cmd>lua vim.lsp.buf.code_action()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<C-A>", "<cmd>lua vim.lsp.buf.code_action()<CR>", {noremap = true})
-- goto next warning/error
--vim.api.nvim_set_keymap("n", "<C-N>", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<C-N>", "<cmd>lua vim.diagnostic.goto_next()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<C-P>", "<cmd>lua vim.diagnostic.goto_prev()<CR>", {noremap = true})
EOF