lsp stuff
This commit is contained in:
@ -1 +1,2 @@
|
|||||||
private
|
private
|
||||||
|
handlePackageIntent
|
||||||
|
Binary file not shown.
0
vim/.vim/lua/cmp.lua
Normal file
0
vim/.vim/lua/cmp.lua
Normal file
@ -4,38 +4,14 @@ require("trouble").setup({
|
|||||||
height = 10, -- height of the trouble list when position is top or bottom
|
height = 10, -- height of the trouble list when position is top or bottom
|
||||||
width = 50, -- width of the list when position is left or right
|
width = 50, -- width of the list when position is left or right
|
||||||
icons = true, -- use devicons for filenames
|
icons = true, -- use devicons for filenames
|
||||||
-- mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
|
||||||
mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
|
||||||
fold_open = "", -- icon used for open folds
|
-- fold_open = "", -- icon used for open folds
|
||||||
fold_closed = "", -- icon used for closed folds
|
-- fold_closed = "", -- icon used for closed folds
|
||||||
group = true, -- group results by file
|
group = true, -- group results by file
|
||||||
padding = true, -- add an extra new line on top of the list
|
padding = true, -- add an extra new line on top of the list
|
||||||
action_keys = { -- key mappings for actions in the trouble list
|
|
||||||
-- map to {} to remove a mapping, for example:
|
|
||||||
-- close = {},
|
|
||||||
close = "q", -- close the list
|
|
||||||
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
|
|
||||||
refresh = "r", -- manually refresh
|
|
||||||
jump = { "<cr>", "<tab>" }, -- jump to the diagnostic or open / close folds
|
|
||||||
open_split = { "<c-x>" }, -- open buffer in new split
|
|
||||||
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
|
|
||||||
open_tab = { "<c-t>" }, -- open buffer in new tab
|
|
||||||
jump_close = { "o" }, -- jump to the diagnostic and close the list
|
|
||||||
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
|
|
||||||
toggle_preview = "P", -- toggle auto_preview
|
|
||||||
hover = "L", -- opens a small popup with the full multiline message
|
|
||||||
preview = "p", -- preview the diagnostic location
|
|
||||||
close_folds = { "zM", "zm" }, -- close all folds
|
|
||||||
open_folds = { "zR", "zr" }, -- open all folds
|
|
||||||
toggle_fold = { "zA", "za" }, -- toggle fold of current file
|
|
||||||
previous = "k", -- preview item
|
|
||||||
next = "j", -- next item
|
|
||||||
},
|
|
||||||
indent_lines = true, -- add an indent guide below the fold icons
|
indent_lines = true, -- add an indent guide below the fold icons
|
||||||
auto_open = false, -- automatically open the list when you have diagnostics
|
auto_open = false, -- automatically open the list when you have diagnostics
|
||||||
auto_close = true, -- automatically close the list when you have no diagnostics
|
auto_close = true, -- automatically close the list when you have no diagnostics
|
||||||
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
|
|
||||||
auto_fold = false, -- automatically fold a file trouble list at creation
|
|
||||||
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
|
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
|
||||||
signs = {
|
signs = {
|
||||||
-- icons / text used for a diagnostic
|
-- icons / text used for a diagnostic
|
||||||
@ -58,3 +34,5 @@ vim.api.nvim_set_keymap("n", "<Leader>xl", "<Cmd>Trouble loclist<CR>", opts)
|
|||||||
vim.api.nvim_set_keymap("n", "<Leader>xq", "<Cmd>Trouble quickfix<CR>", opts)
|
vim.api.nvim_set_keymap("n", "<Leader>xq", "<Cmd>Trouble quickfix<CR>", opts)
|
||||||
vim.api.nvim_set_keymap("n", "[g", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
vim.api.nvim_set_keymap("n", "[g", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||||
vim.api.nvim_set_keymap("n", "]g", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
vim.api.nvim_set_keymap("n", "]g", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||||
|
|
||||||
|
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
-- 1. Configure CiderLSP
|
|
||||||
local use_google = require("utils").use_google
|
local use_google = require("utils").use_google
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
local configs = require("lspconfig.configs")
|
|
||||||
local notify = require 'notify'
|
local notify = require 'notify'
|
||||||
|
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
@ -12,16 +9,142 @@ require("mason-lspconfig").setup({
|
|||||||
local lsp = require('lsp-zero')
|
local lsp = require('lsp-zero')
|
||||||
lsp.preset('manual-setup')
|
lsp.preset('manual-setup')
|
||||||
|
|
||||||
local rust_lsp = lsp.build_options('rust_analyzer', {})
|
|
||||||
|
|
||||||
lsp.nvim_workspace()
|
lsp.nvim_workspace()
|
||||||
lsp.setup()
|
lsp.setup()
|
||||||
|
|
||||||
|
-- Initialize rust_analyzer with rust-tools
|
||||||
|
local rust_lsp = lsp.build_options('rust_analyzer', {})
|
||||||
|
require('rust-tools').setup({server = rust_lsp})
|
||||||
|
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
local configs = require("lspconfig.configs")
|
||||||
|
if use_google() then
|
||||||
|
configs.ciderlsp = {
|
||||||
|
default_config = {
|
||||||
|
cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-cmp", "--forward_sync_responses" },
|
||||||
|
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
||||||
|
root_dir = lspconfig.util.root_pattern("BUILD"),
|
||||||
|
settings = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
configs.analysislsp = {
|
||||||
|
default_config = {
|
||||||
|
cmd = { '/google/bin/users/lerm/glint-ale/analysis_lsp/server', '--lint_on_save=false', '--max_qps=10', },
|
||||||
|
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
||||||
|
root_dir = lspconfig.util.root_pattern('BUILD'),
|
||||||
|
settings = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local cider_lsp_handlers = {
|
||||||
|
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
|
underline = true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
|
||||||
|
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
|
||||||
|
-- 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["workspace/diagnostic/refresh"] = function(_, result, ctx)
|
||||||
|
notify('result:'..result, 'info', {timeout=900})
|
||||||
|
notify('ctx:'..ctx, 'info', {timeout=900})
|
||||||
|
end
|
||||||
|
|
||||||
|
cider_lsp_handlers['window/showMessage'] = function(_, result, ctx)
|
||||||
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
|
local lvl = ({
|
||||||
|
'ERROR',
|
||||||
|
'WARN',
|
||||||
|
'INFO',
|
||||||
|
'DEBUG',
|
||||||
|
})[result.type]
|
||||||
|
notify({ result.message }, lvl, {
|
||||||
|
title = 'LSP | ' .. client.name,
|
||||||
|
timeout = 1000,
|
||||||
|
keep = function()
|
||||||
|
return lvl == 'ERROR' or lvl == 'WARN'
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local lsp_status = require('lsp-status')
|
||||||
|
|
||||||
|
-- 3. Set up CiderLSP
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
vim.b['is_cider_lsp_attached'] = 'no'
|
||||||
|
require('lualine').refresh()
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
if vim.lsp.formatexpr then -- Neovim v0.6.0+ only.
|
||||||
|
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
|
||||||
|
|
||||||
|
if client.server_capabilities.document_highlight then
|
||||||
|
vim.api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()")
|
||||||
|
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()")
|
||||||
|
end
|
||||||
|
|
||||||
|
lsp_status.on_attach(client, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
vim.api.nvim_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "L", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "gD", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("n", "grf", "<cmd>lua vim.lsp.buf.references()<CR>", opts) -- diagnostics controls references
|
||||||
|
vim.api.nvim_set_keymap("n", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||||
|
vim.api.nvim_set_keymap("i", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||||
|
|
||||||
|
|
||||||
|
local 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
|
||||||
|
}
|
||||||
|
|
||||||
|
lsp_status.register_progress()
|
||||||
|
capabilities = vim.tbl_extend('keep', capabilities or {}, lsp_status.capabilities)
|
||||||
|
|
||||||
local runtime_path = vim.split(package.path, ";")
|
local runtime_path = vim.split(package.path, ";")
|
||||||
table.insert(runtime_path, "lua/?.lua")
|
table.insert(runtime_path, "lua/?.lua")
|
||||||
table.insert(runtime_path, "lua/?/init.lua")
|
table.insert(runtime_path, "lua/?/init.lua")
|
||||||
|
|
||||||
lspconfig.sumneko_lua.setup({
|
lspconfig.sumneko_lua.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
@ -46,35 +169,32 @@ lspconfig.sumneko_lua.setup({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Initialize rust_analyzer with rust-tools
|
|
||||||
require('rust-tools').setup({server = rust_lsp})
|
|
||||||
if use_google() then
|
if use_google() then
|
||||||
configs.ciderlsp = {
|
capabilities = require('cmp_nvim_ciderlsp').update_capabilities(capabilities)
|
||||||
default_config = {
|
capabilities.workspace.codeLens = {refreshSupport=true}
|
||||||
cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-cmp", "--forward_sync_responses" },
|
capabilities.workspace.diagnostics = {refreshSupport=true}
|
||||||
-- cmd = {'/google/bin/releases/cider/ciderlsp/ciderlsp', '--forward_sync_responses', '--enable_document_highlight'};
|
lspconfig.ciderlsp.setup({
|
||||||
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
capabilities = capabilities,
|
||||||
root_dir = lspconfig.util.root_pattern("BUILD"),
|
on_attach = on_attach,
|
||||||
settings = {},
|
handlers = cider_lsp_handlers,
|
||||||
},
|
})
|
||||||
}
|
lspconfig.analysislsp.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local lspkind = require("lspkind")
|
||||||
|
lspkind.init()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 2. Configure CMP
|
local feedkey = function(key, mode)
|
||||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
-- Don't show the dumb matching stuff
|
|
||||||
vim.opt.shortmess:append("c")
|
|
||||||
|
|
||||||
local lspkind = require("lspkind")
|
|
||||||
lspkind.init()
|
|
||||||
|
|
||||||
local cmp = require("cmp")
|
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
@ -114,8 +234,10 @@ local conditionalSources = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local use_google = require("utils").use_google
|
||||||
if use_google() then
|
if use_google() then
|
||||||
table.insert(conditionalSources, { name = 'nvim_ciderlsp', priority = 9 })
|
table.insert(conditionalSources, { name = 'nvim_ciderlsp', priority = 9 })
|
||||||
|
table.insert(conditionalSources, { name = 'analysislsp', priority = 9 })
|
||||||
end
|
end
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
@ -170,28 +292,7 @@ cmp.setup({
|
|||||||
sources = conditionalSources,
|
sources = conditionalSources,
|
||||||
|
|
||||||
sorting = {
|
sorting = {
|
||||||
comparators = {
|
comparators = { },
|
||||||
cmp.config.compare.offset,
|
|
||||||
cmp.config.compare.exact,
|
|
||||||
cmp.config.compare.score,
|
|
||||||
|
|
||||||
function(entry1, entry2)
|
|
||||||
local _, entry1_under = entry1.completion_item.label:find("^_+")
|
|
||||||
local _, entry2_under = entry2.completion_item.label:find("^_+")
|
|
||||||
entry1_under = entry1_under or 0
|
|
||||||
entry2_under = entry2_under or 0
|
|
||||||
if entry1_under > entry2_under then
|
|
||||||
return false
|
|
||||||
elseif entry1_under < entry2_under then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
cmp.config.compare.kind,
|
|
||||||
cmp.config.compare.sort_text,
|
|
||||||
cmp.config.compare.length,
|
|
||||||
cmp.config.compare.order,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
@ -205,12 +306,12 @@ cmp.setup({
|
|||||||
with_text = true,
|
with_text = true,
|
||||||
maxwidth = 40, -- half max width
|
maxwidth = 40, -- half max width
|
||||||
menu = {
|
menu = {
|
||||||
-- nvim_ciderlsp = "[]",
|
|
||||||
nvim_ciderlsp = "",
|
nvim_ciderlsp = "",
|
||||||
buffer = "",
|
buffer = "",
|
||||||
nvim_lsp = "[CiderLSP]",
|
nvim_lsp = "[CiderLSP]",
|
||||||
nvim_lua = "[API]",
|
nvim_lua = "[API]",
|
||||||
path = "[path]",
|
path = "[path]",
|
||||||
|
tmux = "[TMUX]",
|
||||||
vim_vsnip = "[snip]",
|
vim_vsnip = "[snip]",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -229,105 +330,3 @@ autocmd Filetype zsh lua require'cmp'.setup.buffer { sources = { { name = "zsh"
|
|||||||
augroup END
|
augroup END
|
||||||
]])
|
]])
|
||||||
|
|
||||||
local cider_lsp_handlers = {
|
|
||||||
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
||||||
underline = true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
|
|
||||||
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
|
|
||||||
-- 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["workspace/diagnostic/refresh"] = function(_, result, ctx)
|
|
||||||
notify('result:'..result, 'info', {timeout=900})
|
|
||||||
notify('ctx:'..ctx, 'info', {timeout=900})
|
|
||||||
end
|
|
||||||
|
|
||||||
cider_lsp_handlers['window/showMessage'] = function(_, result, ctx)
|
|
||||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
|
||||||
local lvl = ({
|
|
||||||
'ERROR',
|
|
||||||
'WARN',
|
|
||||||
'INFO',
|
|
||||||
'DEBUG',
|
|
||||||
})[result.type]
|
|
||||||
notify({ result.message }, lvl, {
|
|
||||||
title = 'LSP | ' .. client.name,
|
|
||||||
timeout = 1000,
|
|
||||||
keep = function()
|
|
||||||
return lvl == 'ERROR' or lvl == 'WARN'
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 3. Set up CiderLSP
|
|
||||||
local on_attach = function(client, bufnr)
|
|
||||||
vim.b['is_cider_lsp_attached'] = 'no'
|
|
||||||
require('lualine').refresh()
|
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
|
||||||
if vim.lsp.formatexpr then -- Neovim v0.6.0+ only.
|
|
||||||
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
|
|
||||||
|
|
||||||
if client.server_capabilities.document_highlight then
|
|
||||||
vim.api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()")
|
|
||||||
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()")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "L", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "gD", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>", opts)
|
|
||||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "grf", "<cmd>lua vim.lsp.buf.references()<CR>", opts) -- diagnostics controls references
|
|
||||||
vim.api.nvim_set_keymap("n", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
||||||
vim.api.nvim_set_keymap("i", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
|
||||||
|
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
||||||
capabilities['codeLens'] = {dynamicRegistration=false}
|
|
||||||
-- capabilities.workspace.codeLens = {refreshSupport=true}
|
|
||||||
-- capabilities.workspace.diagnostics = {refreshSupport=true}
|
|
||||||
capabilities.textDocument.publishDiagnostics={
|
|
||||||
relatedInformation=true,
|
|
||||||
versionSupport=false,
|
|
||||||
tagSupport={
|
|
||||||
valueSet={
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
codeDescriptionSupport=true,
|
|
||||||
dataSupport=true,
|
|
||||||
--layeredDiagnostics=true
|
|
||||||
}
|
|
||||||
if use_google() then
|
|
||||||
capabilities = require('cmp_nvim_ciderlsp').update_capabilities(capabilities)
|
|
||||||
lspconfig.ciderlsp.setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
handlers = cider_lsp_handlers,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
@ -5,9 +5,6 @@ local split = function (inputstr, sep)
|
|||||||
end
|
end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
local function getWords()
|
|
||||||
return tostring(vim.fn.wordcount().words)
|
|
||||||
end
|
|
||||||
local function getCitc()
|
local function getCitc()
|
||||||
local fname = vim.api.nvim_buf_get_name(0)
|
local fname = vim.api.nvim_buf_get_name(0)
|
||||||
if string.find(fname, '/google/src/cloud/', 1, true) then
|
if string.find(fname, '/google/src/cloud/', 1, true) then
|
||||||
@ -15,7 +12,7 @@ local function getCitc()
|
|||||||
return parts[5]
|
return parts[5]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function isCiderLspAttached()
|
local function isCiderLspAttached()
|
||||||
if vim.b['is_cider_lsp_attached'] then
|
if vim.b['is_cider_lsp_attached'] then
|
||||||
if vim.b['is_cider_lsp_attached'] == 'yes' then
|
if vim.b['is_cider_lsp_attached'] == 'yes' then
|
||||||
return '✓'
|
return '✓'
|
||||||
@ -26,6 +23,7 @@ function isCiderLspAttached()
|
|||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getLightbulb()
|
local function getLightbulb()
|
||||||
return require('nvim-lightbulb').get_status_text()
|
return require('nvim-lightbulb').get_status_text()
|
||||||
end
|
end
|
||||||
@ -56,7 +54,7 @@ require('lualine').setup {
|
|||||||
sections = {
|
sections = {
|
||||||
lualine_a = {'mode'},
|
lualine_a = {'mode'},
|
||||||
lualine_b = {'branch', 'diff', getCitc, isCiderLspAttached},
|
lualine_b = {'branch', 'diff', getCitc, isCiderLspAttached},
|
||||||
lualine_c = {'filename', {"aerial", depth=-1}, getLightbulb},
|
lualine_c = {'filename', 'lsp_progress', getLightbulb},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
{ 'diagnostics', sources = {"nvim_lsp"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
{ 'diagnostics', sources = {"nvim_lsp"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
||||||
'encoding',
|
'encoding',
|
||||||
@ -69,7 +67,7 @@ require('lualine').setup {
|
|||||||
lualine_a = {{'tabs', mode = 1}},
|
lualine_a = {{'tabs', mode = 1}},
|
||||||
-- lualine_b = {'branch'},
|
-- lualine_b = {'branch'},
|
||||||
-- lualine_c = {'filename'},
|
-- lualine_c = {'filename'},
|
||||||
lualine_x = {
|
lualine_c = {
|
||||||
{ 'diagnostics', sources = {"nvim_lsp", "nvim_workspace_diagnostic"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
{ 'diagnostics', sources = {"nvim_lsp", "nvim_workspace_diagnostic"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
||||||
},
|
},
|
||||||
-- lualine_y = { getLGTMs }
|
-- lualine_y = { getLGTMs }
|
||||||
|
25
vim/.vim/lua/null_lsp.lua
Normal file
25
vim/.vim/lua/null_lsp.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
|
local sources = {
|
||||||
|
-- Catch insensitive, inconsiderate writing.
|
||||||
|
null_ls.builtins.diagnostics.alex,
|
||||||
|
|
||||||
|
-- buildifier is a tool for formatting and linting bazel BUILD, WORKSPACE, and .bzl files.
|
||||||
|
null_ls.builtins.diagnostics.buildifier,
|
||||||
|
|
||||||
|
-- Codespell finds common misspellings in text files.
|
||||||
|
-- null_ls.builtins.diagnostics.codespell,
|
||||||
|
-- null_ls.builtins.diagnostics.cspell, null_ls.builtins.code_actions.cspell,
|
||||||
|
|
||||||
|
-- An English prose linter. Can fix some issues via code actions.
|
||||||
|
null_ls.builtins.code_actions.proselint,
|
||||||
|
|
||||||
|
-- Reformats Java source code according to Google Java Style.
|
||||||
|
null_ls.builtins.formatting.google_java_format
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
null_ls.setup({
|
||||||
|
sources = sources,
|
||||||
|
})
|
@ -13,8 +13,6 @@ autocmd BufWritePost plugins.lua source <afile> | PackerCompile
|
|||||||
augroup end
|
augroup end
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require('packer').startup(function(use)
|
require('packer').startup(function(use)
|
||||||
-- Packer can manage itself
|
-- Packer can manage itself
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
@ -73,6 +71,10 @@ require('packer').startup(function(use)
|
|||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
'VonHeikemen/lsp-zero.nvim',
|
'VonHeikemen/lsp-zero.nvim',
|
||||||
}
|
}
|
||||||
|
use {
|
||||||
|
'jose-elias-alvarez/null-ls.nvim',
|
||||||
|
config = [[ require("null_lsp") ]]
|
||||||
|
}
|
||||||
use 'simrat39/rust-tools.nvim'
|
use 'simrat39/rust-tools.nvim'
|
||||||
use 'folke/trouble.nvim'
|
use 'folke/trouble.nvim'
|
||||||
|
|
||||||
@ -100,7 +102,10 @@ require('packer').startup(function(use)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
-- 'sso://googler@user/lerm/glint-ale',
|
||||||
|
-- 'dense-analysis/ale',
|
||||||
'sso://googler@user/vintharas/telescope-codesearch.nvim',
|
'sso://googler@user/vintharas/telescope-codesearch.nvim',
|
||||||
disable = not use_google(),
|
disable = not use_google(),
|
||||||
}
|
}
|
||||||
@ -121,6 +126,7 @@ require('packer').startup(function(use)
|
|||||||
config = [[ require("critique").setup() ]]
|
config = [[ require("critique").setup() ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use 'nvim-lua/lsp-status.nvim'
|
||||||
use {
|
use {
|
||||||
'nvim-lualine/lualine.nvim',
|
'nvim-lualine/lualine.nvim',
|
||||||
config = [[ require("lualine_config") ]]
|
config = [[ require("lualine_config") ]]
|
||||||
@ -202,9 +208,12 @@ end)
|
|||||||
|
|
||||||
-- CiderLSP
|
-- CiderLSP
|
||||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||||
|
-- Don't show the dumb matching stuff
|
||||||
|
vim.opt.shortmess:append("c")
|
||||||
|
|
||||||
require('lspconfig')
|
require('lspconfig')
|
||||||
require("lsp")
|
require("lsp")
|
||||||
|
|
||||||
require("diagnostics")
|
require("diagnostics")
|
||||||
require("treesitter")
|
require("treesitter")
|
||||||
require("telescope_config")
|
require("telescope_config")
|
||||||
|
@ -22,7 +22,7 @@ function M.dump(o)
|
|||||||
local s = '{ '
|
local s = '{ '
|
||||||
for k,v in pairs(o) do
|
for k,v in pairs(o) do
|
||||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||||
s = s .. '['..k..'] = ' .. dump(v) .. ','
|
s = s .. '['..k..'] = ' .. M.dump(v) .. ','
|
||||||
end
|
end
|
||||||
return s .. '} '
|
return s .. '} '
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user