-- 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.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') -- scroll down hover doc or scroll in definition preview 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('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') --[[ " 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 lua require('jdtls').code_action() local lsp_config = {} function lsp_config.common_on_attach(client, bufnr) -- Set autocommands conditional on server_capabilities if client.resolved_capabilities.document_highlight then 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 augroup lsp_document_highlight autocmd! * autocmd CursorHold lua vim.lsp.buf.document_highlight() autocmd CursorMoved lua vim.lsp.buf.clear_references() augroup END ]], false) end end -- Use a loop to conveniently both setup defined servers -- and map buffer local keybindings when the language server attaches -- local servers = {"pyright", "tsserver"} -- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end return lsp_config