meep
This commit is contained in:
@ -1,219 +1,197 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
-- event = "VimEnter",
|
-- event = "VimEnter",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
"nvim-lua/lsp-status.nvim",
|
"nvim-lua/lsp-status.nvim",
|
||||||
"VonHeikemen/lsp-zero.nvim",
|
"VonHeikemen/lsp-zero.nvim",
|
||||||
"rcarriga/nvim-notify",
|
"rcarriga/nvim-notify",
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>" },
|
{ "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>" },
|
||||||
{ "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>" },
|
{ "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>" },
|
||||||
{ "L", "<cmd>lua vim.lsp.buf.hover()<CR>" },
|
{ "L", "<cmd>lua vim.lsp.buf.hover()<CR>" },
|
||||||
{ "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>" },
|
{ "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>" },
|
||||||
{ "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>" },
|
{ "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>" },
|
||||||
{ "gd", "<cmd>lua vim.lsp.buf.definition()<CR>" },
|
{ "gd", "<cmd>lua vim.lsp.buf.definition()<CR>" },
|
||||||
{ "gD", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>" },
|
{ "gD", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>" },
|
||||||
{ "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>" },
|
{ "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>" },
|
||||||
{ "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>" },
|
{ "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>" },
|
||||||
{ "gR", "<cmd>lua vim.lsp.buf.references()<CR>" },
|
{ "gR", "<cmd>lua vim.lsp.buf.references()<CR>" },
|
||||||
{ "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>" },
|
{ "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>" },
|
||||||
{ "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>" },
|
{ "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>" },
|
||||||
{ "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", mode = "i" },
|
{ "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", mode = "i" },
|
||||||
{ "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", mode = "v" },
|
{ "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", mode = "v" },
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local use_google = require("utils").use_google
|
local use_google = require("utils").use_google
|
||||||
local notify = require("notify")
|
local notify = require("notify")
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
local configs = require("lspconfig.configs")
|
local configs = require("lspconfig.configs")
|
||||||
local lsp_status = require("lsp-status")
|
local lsp_status = require("lsp-status")
|
||||||
lsp_status.register_progress()
|
lsp_status.register_progress()
|
||||||
|
|
||||||
-- CiderLSP
|
-- CiderLSP
|
||||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||||
-- Don't show the dumb matching stuff
|
-- Don't show the dumb matching stuff
|
||||||
vim.opt.shortmess:append("c")
|
vim.opt.shortmess:append("c")
|
||||||
|
|
||||||
vim.opt.spell = true
|
vim.opt.spell = true
|
||||||
vim.opt.spelllang = { "en_us" }
|
vim.opt.spelllang = { "en_us" }
|
||||||
vim.lsp.handlers["window/showMessage"] = function(_, result, ctx)
|
vim.lsp.handlers["window/showMessage"] = function(_, result, ctx)
|
||||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
local lvl = ({
|
local lvl = ({
|
||||||
"ERROR",
|
"ERROR",
|
||||||
"WARN",
|
"WARN",
|
||||||
"INFO",
|
"INFO",
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
})[result.type]
|
})[result.type]
|
||||||
notify({ result.message }, lvl, {
|
notify({ result.message }, lvl, {
|
||||||
title = "LSP | " .. client.name,
|
title = "LSP | " .. client.name,
|
||||||
timeout = 1000,
|
timeout = 1000,
|
||||||
keep = function()
|
keep = function()
|
||||||
return lvl == "ERROR" or lvl == "WARN"
|
return lvl == "ERROR" or lvl == "WARN"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
configs.ast_grep = {
|
if use_google() then
|
||||||
default_config = {
|
configs.ciderlsp = {
|
||||||
cmd = { "sg", "lsp" },
|
default_config = {
|
||||||
offset_encoding = "utf-8",
|
cmd = {
|
||||||
filetypes = {
|
"/google/bin/releases/cider/ciderlsp/ciderlsp",
|
||||||
"c",
|
"--tooltag=nvim-cmp",
|
||||||
"cpp",
|
"--forward_sync_responses",
|
||||||
"java",
|
},
|
||||||
"kotlin",
|
offset_encoding = "utf-8",
|
||||||
"objc",
|
filetypes = {
|
||||||
"proto",
|
"c",
|
||||||
"textproto",
|
"cpp",
|
||||||
"go",
|
"java",
|
||||||
"python",
|
"kotlin",
|
||||||
"bzl",
|
"objc",
|
||||||
"typescript",
|
"proto",
|
||||||
},
|
"textproto",
|
||||||
single_file_support = true,
|
"go",
|
||||||
root_dir = lspconfig.util.root_pattern("BUILD", ".git", "sgconfig.yml"),
|
"python",
|
||||||
},
|
"bzl",
|
||||||
}
|
"typescript",
|
||||||
|
},
|
||||||
|
-- required for proto generated files jump
|
||||||
|
root_dir = function(fname)
|
||||||
|
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
|
||||||
|
end,
|
||||||
|
settings = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
if use_google() then
|
configs.analysislsp = {
|
||||||
configs.ciderlsp = {
|
default_config = {
|
||||||
default_config = {
|
cmd = {
|
||||||
cmd = {
|
"/google/bin/users/lerm/glint-ale/analysis_lsp/server",
|
||||||
"/google/bin/releases/cider/ciderlsp/ciderlsp",
|
"--lint_on_save=false",
|
||||||
"--tooltag=nvim-cmp",
|
"--max_qps=10",
|
||||||
"--forward_sync_responses",
|
},
|
||||||
},
|
offset_encoding = "utf-8",
|
||||||
offset_encoding = "utf-8",
|
filetypes = {
|
||||||
filetypes = {
|
"c",
|
||||||
"c",
|
"cpp",
|
||||||
"cpp",
|
"java",
|
||||||
"java",
|
"kotlin",
|
||||||
"kotlin",
|
"objc",
|
||||||
"objc",
|
"proto",
|
||||||
"proto",
|
"textproto",
|
||||||
"textproto",
|
"go",
|
||||||
"go",
|
"python",
|
||||||
"python",
|
"bzl",
|
||||||
"bzl",
|
"markdown",
|
||||||
"typescript",
|
"typescript",
|
||||||
},
|
"javascript",
|
||||||
-- required for proto generated files jump
|
},
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
|
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
|
||||||
end,
|
end,
|
||||||
settings = {},
|
settings = {},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
configs.analysislsp = {
|
local capabilities =
|
||||||
default_config = {
|
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
cmd = {
|
capabilities["codeLens"] = { dynamicRegistration = false }
|
||||||
"/google/bin/users/lerm/glint-ale/analysis_lsp/server",
|
capabilities.textDocument.publishDiagnostics = {
|
||||||
"--lint_on_save=false",
|
relatedInformation = true,
|
||||||
"--max_qps=10",
|
versionSupport = false,
|
||||||
},
|
tagSupport = {
|
||||||
offset_encoding = "utf-8",
|
valueSet = {
|
||||||
filetypes = {
|
1,
|
||||||
"c",
|
2,
|
||||||
"cpp",
|
},
|
||||||
"java",
|
},
|
||||||
"kotlin",
|
codeDescriptionSupport = true,
|
||||||
"objc",
|
dataSupport = true,
|
||||||
"proto",
|
layeredDiagnostics = true,
|
||||||
"textproto",
|
}
|
||||||
"go",
|
|
||||||
"python",
|
|
||||||
"bzl",
|
|
||||||
"markdown",
|
|
||||||
"typescript",
|
|
||||||
"javascript",
|
|
||||||
},
|
|
||||||
root_dir = function(fname)
|
|
||||||
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
|
|
||||||
end,
|
|
||||||
settings = {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local capabilities =
|
capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities)
|
||||||
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
||||||
capabilities["codeLens"] = { dynamicRegistration = false }
|
|
||||||
capabilities.textDocument.publishDiagnostics = {
|
|
||||||
relatedInformation = true,
|
|
||||||
versionSupport = false,
|
|
||||||
tagSupport = {
|
|
||||||
valueSet = {
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
codeDescriptionSupport = true,
|
|
||||||
dataSupport = true,
|
|
||||||
layeredDiagnostics = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities)
|
local my_on_attach = function(client, bufnr)
|
||||||
|
require("lualine").refresh()
|
||||||
|
|
||||||
local my_on_attach = function(client, bufnr)
|
vim.api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()")
|
||||||
require("lualine").refresh()
|
vim.api.nvim_command("autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()")
|
||||||
|
vim.api.nvim_command("autocmd CursorMoved <buffer> lua vim.lsp.util.buf_clear_references()")
|
||||||
|
|
||||||
vim.api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()")
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
vim.api.nvim_command("autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()")
|
if vim.lsp.formatexpr then -- Neovim v0.6.0+ only.
|
||||||
vim.api.nvim_command("autocmd CursorMoved <buffer> lua vim.lsp.util.buf_clear_references()")
|
vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr")
|
||||||
|
end
|
||||||
|
if vim.lsp.tagfunc then
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||||
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
lsp_status.on_attach(client)
|
||||||
if vim.lsp.formatexpr then -- Neovim v0.6.0+ only.
|
end
|
||||||
vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr")
|
|
||||||
end
|
|
||||||
if vim.lsp.tagfunc then
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
|
||||||
end
|
|
||||||
|
|
||||||
lsp_status.on_attach(client)
|
if use_google() then
|
||||||
end
|
local cider_on_attach = function(client, bufnr)
|
||||||
|
my_on_attach(client, bufnr)
|
||||||
|
vim.b["is_cider_lsp_attached"] = "no"
|
||||||
|
end
|
||||||
|
|
||||||
if use_google() then
|
local cider_lsp_handlers = {
|
||||||
local cider_on_attach = function(client, bufnr)
|
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
my_on_attach(client, bufnr)
|
underline = true,
|
||||||
vim.b["is_cider_lsp_attached"] = "no"
|
}),
|
||||||
end
|
}
|
||||||
|
|
||||||
local cider_lsp_handlers = {
|
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
|
||||||
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
|
||||||
underline = true,
|
-- sync response yet.
|
||||||
}),
|
local first_fire = vim.b["is_cider_lsp_attached"] == "no"
|
||||||
}
|
vim.b["is_cider_lsp_attached"] = "yes"
|
||||||
|
if first_fire then
|
||||||
|
notify("CiderLSP attached", "info", { timeout = 500 })
|
||||||
|
require("lualine").refresh()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
|
capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities)
|
||||||
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
|
capabilities.workspace.codeLens = { refreshSupport = true }
|
||||||
-- sync response yet.
|
capabilities.workspace.diagnostics = { refreshSupport = true }
|
||||||
local first_fire = vim.b["is_cider_lsp_attached"] == "no"
|
|
||||||
vim.b["is_cider_lsp_attached"] = "yes"
|
|
||||||
if first_fire then
|
|
||||||
notify("CiderLSP attached", "info", { timeout = 500 })
|
|
||||||
require("lualine").refresh()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities)
|
lspconfig.analysislsp.setup({
|
||||||
capabilities.workspace.codeLens = { refreshSupport = true }
|
capabilities = capabilities,
|
||||||
capabilities.workspace.diagnostics = { refreshSupport = true }
|
})
|
||||||
|
|
||||||
lspconfig.analysislsp.setup({
|
lspconfig.ciderlsp.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
on_attach = cider_on_attach,
|
||||||
|
handlers = cider_lsp_handlers,
|
||||||
lspconfig.ciderlsp.setup({
|
})
|
||||||
capabilities = capabilities,
|
end
|
||||||
on_attach = cider_on_attach,
|
end,
|
||||||
handlers = cider_lsp_handlers,
|
},
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user