diff options
-rw-r--r-- | init.lua | 3 | ||||
-rw-r--r-- | lua/lsp/init.lua | 36 | ||||
-rw-r--r-- | lua/nv-nvimtree/init.lua | 22 | ||||
-rw-r--r-- | lua/settings.lua | 2 | ||||
-rw-r--r-- | lua/utils.lua | 29 |
5 files changed, 91 insertions, 1 deletions
@@ -15,4 +15,7 @@ require('nv-nvim-autopairs') require('nv-kommentary') -- LSP +require('lsp') +require('utils') require('lsp.lua-ls') + diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index e69de29b..b3d157ea 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -0,0 +1,36 @@ +--TODO figure out why this don't work +vim.fn.sign_define("LspDiagnosticsSignError", {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}) +vim.fn.sign_define("LspDiagnosticsSignWarning", {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}) +vim.fn.sign_define("LspDiagnosticsSignInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) +vim.fn.sign_define("LspDiagnosticsSignHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) + +--[[ vim.fn.sign_define("LspDiagnosticsVirtualTextError", {texthl = "LspDiagnosticsVirtualTextError", text = "", numhl = "LspDiagnosticsVirtualTextError"}) +vim.fn.sign_define("LspDiagnosticsVirtualTextWarning", {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}) +vim.fn.sign_define("LspDiagnosticsVirtualTextInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) +vim.fn.sign_define("LspDiagnosticsVirtualTextHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) ]] + +--[[ vim.fn.sign_define("LspDiagnosticsSignError", {text = ""}) +vim.fn.sign_define("LspDiagnosticsSignWarning", {text = ""}) +vim.fn.sign_define("LspDiagnosticsSignInformation", {text = ""}) +vim.fn.sign_define("LspDiagnosticsSignHint", {text = ""}) ]] + +--[[ vim.fn.sign_define("LspDiagnosticsSignError", { text = " 🞮", numhl = "LspDiagnosticsDefaultError" }) +vim.fn.sign_define("LspDiagnosticsSignWarning", { text = " ▲", numhl = "LspDiagnosticsDefaultWarning" }) +vim.fn.sign_define("LspDiagnosticsSignInformation", { text = " ⁈", numhl = "LspDiagnosticsDefaultInformation" }) +vim.fn.sign_define("LspDiagnosticsSignHint", { text = " ⯁", numhl = "LspDiagnosticsDefaultHint" }) ]] + +vim.cmd('nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>') +vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>') +vim.cmd('nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>') +vim.cmd('nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>') +vim.cmd('nnoremap <silent> ca :Lspsaga code_action<CR>') +vim.cmd('nnoremap <silent> K :Lspsaga hover_doc<CR>') +vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>') +vim.cmd('nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>') +vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>') +--[[ " autoformat +autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] +-- Java +-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> diff --git a/lua/nv-nvimtree/init.lua b/lua/nv-nvimtree/init.lua index 3803765a..b980aca2 100644 --- a/lua/nv-nvimtree/init.lua +++ b/lua/nv-nvimtree/init.lua @@ -1,3 +1,25 @@ +--[[ " +--let g:nvim_tree_auto_ignore_ft = 'startify' "empty by default, don't auto open tree on specific filetypes. +let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.` +let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). +" let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open +" let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file +let g:nvim_tree_show_icons = { + \ 'git': 1, + \ 'folders': 1, + \ 'files': 1, + \ } +"If 0, do not show the icons for one of 'git' 'folder' and 'files' +"1 by default, notice that if 'files' is 1, it will only display +"if nvim-web-devicons is installed and on your runtimepath ]] +-- vim.g.nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default +vim.g.nvim_tree_disable_netrw = 0 --"1 by default, disables netrw +vim.g.nvim_tree_hijack_netrw = 0 --"1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities) +vim.g.nvim_tree_hide_dotfiles = 1 --0 by default, this option hides files and folders starting with a dot `.` +vim.g.nvim_tree_indent_markers = 1 --"0 by default, this option shows indent markers when folders are open +vim.g.nvim_tree_follow = 1 --"0 by default, this option allows the cursor to be updated when entering a buffer +vim.g.nvim_tree_auto_close = 1 --0 by default, closes the tree when it's the last window +vim.g.nvim_tree_auto_ignore_ft = 'startify' --"empty by default, don't auto open tree on specific filetypes. local tree_cb = require'nvim-tree.config'.nvim_tree_callback vim.g.nvim_tree_bindings = { -- mappings diff --git a/lua/settings.lua b/lua/settings.lua index fbf24713..99b72622 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -31,7 +31,7 @@ vim.o.showtabline=2 --Always show tabs vim.o.showmode=false --We don't need to see things like -- INSERT -- anymore vim.o.backup=false --This is recommended by coc vim.o.writebackup=false --This is recommended by coc -vim.o.signcolumn="yes" --Always show the signcolumn, otherwise it would shift the text each time +vim.wo.signcolumn="yes" --Always show the signcolumn, otherwise it would shift the text each time vim.o.updatetime=300 --Faster completion vim.o.timeoutlen=1000 --By default timeoutlen is 1000 ms vim.o.clipboard="unnamedplus" --Copy paste between vim and everything else diff --git a/lua/utils.lua b/lua/utils.lua new file mode 100644 index 00000000..59c905f1 --- /dev/null +++ b/lua/utils.lua @@ -0,0 +1,29 @@ +local function define_augroups(definitions) -- {{{1 + -- Create autocommand groups based on the passed definitions + -- + -- The key will be the name of the group, and each definition + -- within the group should have: + -- 1. Trigger + -- 2. Pattern + -- 3. Text + -- just like how they would normally be defined from Vim itself + for group_name, definition in pairs(definitions) do + vim.cmd('augroup ' .. group_name) + vim.cmd('autocmd!') + + for _, def in pairs(definition) do + local command = table.concat(vim.tbl_flatten {'autocmd', def}, ' ') + vim.cmd(command) + end + + vim.cmd('augroup END') + end +end + +define_augroups( + {_general_settings = { + {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'IncSearch\', timeout = 200})'}, + }, + } +) + |