diff --git a/nvim/lua/darcula/keymaps.lua b/nvim/lua/darcula/keymaps.lua index 0a24855..54d145f 100644 --- a/nvim/lua/darcula/keymaps.lua +++ b/nvim/lua/darcula/keymaps.lua @@ -565,6 +565,28 @@ if not NV_DARCULA_ENABLE_COC then function M.lsp() local opts = {remap = false, silent = true} + km.vmap( + km.leader "gs", + function() + telescope_builtin.live_grep({default_text = utils.get_visual_text()}) + end, + opts + ) + km.nmap( + km.leader "gs", + function() + telescope_builtin.live_grep({default_text = utils.cword()}) + end, + opts + ) + km.map( + km.leader "is", + function() + local status = vim.lsp.status() + vim.notify(status ~= "" and status or "None", vim.log.levels.INFO) + end, + opts + ) km.nmap(km.leader "dl", vim.diagnostic.setloclist, opts) km.nmap(km.leader "dw", telescope_builtin.diagnostics, opts) km.nmap(km.leader "fs", telescope_builtin.lsp_document_symbols, opts) @@ -635,14 +657,41 @@ if not NV_DARCULA_ENABLE_COC then local opts = {remap = false, silent = true, buffer = ev.buf} + km.set({"n", "x"}, km.leader "a", vim.lsp.buf.code_action, opts) + km.nmap(km.leader "ac", vim.lsp.buf.code_action, opts) km.nmap(km.leader "aw", vim.lsp.buf.code_action, opts) km.nmap(km.leader "ca", vim.lsp.buf.code_action, opts) + km.nmap(km.leader "cl", vim.lsp.codelens.run, opts) km.nmap(km.leader "gD", vim.lsp.buf.declaration, opts) km.nmap(km.leader "gd", telescope_builtin.lsp_definitions, opts) km.nmap(km.leader "gi", telescope_builtin.lsp_implementations, opts) km.nmap(km.leader "gr", telescope_builtin.lsp_references, opts) km.nmap(km.leader "gy", telescope_builtin.lsp_type_definitions, opts) km.nmap(km.leader "rn", vim.lsp.buf.rename, opts) + if client.name == "clangd" then + km.nmap( + km.leader "gh", + function() + vim.cmd("LspClangdSwitchSourceHeader") + end, + opts + ) + end + km.nmap( + km.leader "qf", + function() + vim.lsp.buf.code_action({apply = true, context = {only = {"quickfix"}}}) + end, + opts + ) + km.set( + {"n", "x"}, + km.leader "rs", + function() + vim.lsp.buf.selection_range(1) + end, + opts + ) km.vmap( km.leader "ac", diff --git a/nvim/lua/darcula/setup/100_mason.lua b/nvim/lua/darcula/setup/100_mason.lua index 9fff767..85360dd 100644 --- a/nvim/lua/darcula/setup/100_mason.lua +++ b/nvim/lua/darcula/setup/100_mason.lua @@ -69,18 +69,80 @@ for _, name in pairs(NV_DARCULA_MASON_LSP_LIST) do } } - vim.lsp.config(name, {capabilities = cspell_capabilities}) + vim.lsp.config( + name, + { + capabilities = cspell_capabilities, + init_options = { + defaultSettings = { + enabledLanguageIds = NV_DARCULA_CSPELL_LANGUAGES, + import = {"./"} + } + } + } + ) + elseif name == "jdtls" then + local lombok = + vim.fs.joinpath( + vim.fn.stdpath("data"), + "mason", + "packages", + "jdtls", + "lombok.jar" + ) + vim.env.JDTLS_JVM_ARGS = + table.concat( + { + "-XX:+UseParallelGC", + "-XX:GCTimeRatio=4", + "-XX:AdaptiveSizePolicyWeight=90", + "-Dsun.zip.disableMemoryMapping=true", + "-Xmx4G", + "-Xms4G", + "-Xlog:disable", + "-javaagent:" .. lombok + }, + " " + ) + + vim.lsp.config( + name, + { + settings = { + java = { + import = {maven = {enabled = true}}, + jdt = { + ls = { + lombokSupport = {enabled = true}, + vmargs = vim.env.JDTLS_JVM_ARGS + } + }, + maven = { + downloadSources = false, + updateSnapshots = true + }, + referencesCodeLens = {enabled = NV_DARCULA_ENABLE_CODE_LENS}, + trace = {server = "verbose"} + } + } + } + ) elseif name == "lua_ls" then vim.lsp.config( name, { settings = { Lua = { + codeLens = {enable = NV_DARCULA_ENABLE_CODE_LENS}, completion = { callSnippet = "Replace", keywordSnippet = "Both" }, - diagnostics = {globals = NV_DARCULA_LUA_GLOBALS}, + diagnostics = { + globals = NV_DARCULA_LUA_GLOBALS, + workspaceDelay = 30000 + }, + hint = {enable = NV_DARCULA_ENABLE_INLAY_HINTS}, runtime = { version = "LuaJIT" }, @@ -97,9 +159,9 @@ for _, name in pairs(NV_DARCULA_MASON_LSP_LIST) do -- "core", -- "opt" -- ) - } - -- maxPreload = 1000, - -- preloadFileSize = 200 + }, + maxPreload = 10000, + preloadFileSize = 3000 } } } diff --git a/nvim/lua/darcula/setup/200_lsp.lua b/nvim/lua/darcula/setup/200_lsp.lua index 082ffed..abe37e7 100644 --- a/nvim/lua/darcula/setup/200_lsp.lua +++ b/nvim/lua/darcula/setup/200_lsp.lua @@ -86,7 +86,7 @@ utils.augroup_with_autocmd( end if client:supports_method("textDocument/inlayHint") then - vim.lsp.inlay_hint.enable(NV_DARCULA_ENABLE_INLAY_HINTS) + vim.lsp.inlay_hint.enable(NV_DARCULA_ENABLE_INLAY_HINTS, {bufnr = ev.buf}) end require("darcula.keymaps").lsp_on_attach(ev) diff --git a/nvim/lua/darcula/setup/500_lightbulb.lua b/nvim/lua/darcula/setup/500_lightbulb.lua index a271bc6..1710daf 100644 --- a/nvim/lua/darcula/setup/500_lightbulb.lua +++ b/nvim/lua/darcula/setup/500_lightbulb.lua @@ -28,12 +28,14 @@ require("nvim-lightbulb").setup( hide_in_unfocused_buffer = true, link_highlights = false, sign = { - enabled = true, + enabled = not NV_DARCULA_ENABLE_VIRTUAL_TEXT, text = symbols.status.info, hl = "WarningSign" }, virtual_text = { - enabled = false + enabled = NV_DARCULA_ENABLE_VIRTUAL_TEXT, + text = symbols.status.info, + hl = "DiagnosticVirtualTextInfo" }, float = { enabled = false