From 886b3bde7503671af91585ebdd27b0dc68e655c2 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 15 Apr 2021 13:30:25 -0300 Subject: replace lsp-kind for vim.lsp.protocol.CompletionItemKind native option (#257) --- lua/lsp/init.lua | 82 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 22 deletions(-) (limited to 'lua/lsp') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 9ce6d0d3..7cea89ed 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,28 +1,65 @@ -- 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("LspDiagnosticsSignHint", - {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) -vim.fn.sign_define("LspDiagnosticsSignInformation", - {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) +vim.fn.sign_define( + "LspDiagnosticsSignError", + {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} +) +vim.fn.sign_define( + "LspDiagnosticsSignWarning", + {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} +) +vim.fn.sign_define( + "LspDiagnosticsSignHint", + {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} +) +vim.fn.sign_define( + "LspDiagnosticsSignInformation", + {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} +) -vim.cmd('nnoremap gd lua vim.lsp.buf.definition()') -vim.cmd('nnoremap gD lua vim.lsp.buf.declaration()') -vim.cmd('nnoremap gr lua vim.lsp.buf.references()') -vim.cmd('nnoremap gi lua vim.lsp.buf.implementation()') -vim.cmd('nnoremap ca :Lspsaga code_action') -vim.cmd('nnoremap K :Lspsaga hover_doc') +vim.cmd("nnoremap gd lua vim.lsp.buf.definition()") +vim.cmd("nnoremap gD lua vim.lsp.buf.declaration()") +vim.cmd("nnoremap gr lua vim.lsp.buf.references()") +vim.cmd("nnoremap gi lua vim.lsp.buf.implementation()") +vim.cmd("nnoremap ca :Lspsaga code_action") +vim.cmd("nnoremap K :Lspsaga hover_doc") -- vim.cmd('nnoremap lua vim.lsp.buf.signature_help()') -vim.cmd('nnoremap :Lspsaga diagnostic_jump_prev') -vim.cmd('nnoremap :Lspsaga diagnostic_jump_next') +vim.cmd("nnoremap :Lspsaga diagnostic_jump_prev") +vim.cmd("nnoremap :Lspsaga diagnostic_jump_next") -- scroll down hover doc or scroll in definition preview -vim.cmd('nnoremap lua require(\'lspsaga.action\').smart_scroll_with_saga(1)') +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(1)") -- scroll up hover doc -vim.cmd('nnoremap lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)') +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(-1)") vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') +-- symbols for autocomplete +vim.lsp.protocol.CompletionItemKind = { + "  (Text) ", + "  (Method)", + "  (Function)", + "  (Constructor)", + " ﴲ (Field)", + "[] (Variable)", + "  (Class)", + " ﰮ (Interface)", + "  (Module)", + " 襁 (Property)", + "  (Unit)", + "  (Value)", + " 練 (Enum)", + "  (Keyword)", + " ﬌ (Snippet)", + "  (Color)", + "  (File)", + "  (Reference)", + "  (Folder)", + "  (EnumMember)", + " ﲀ (Constant)", + " ﳤ (Struct)", + "  (Event)", + "  (Operator)", + "  (TypeParameter)" +} + --[[ " autoformat autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) @@ -33,7 +70,8 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] local function documentHighlight(client, bufnr) -- Set autocommands conditional on server_capabilities if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec([[ + vim.api.nvim_exec( + [[ hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 @@ -42,10 +80,10 @@ local function documentHighlight(client, bufnr) autocmd CursorHold lua vim.lsp.buf.document_highlight() autocmd CursorMoved lua vim.lsp.buf.clear_references() augroup END - ]], false) - + ]], + false + ) end - end local lsp_config = {} -- cgit v1.2.3