From d40aad671771256c4977383755637b2961d2cd25 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Fri, 28 Jul 2023 19:43:17 +0000 Subject: [PATCH] stuff idk --- vim/.vim/lua/plugins/cmp.lua | 32 ++- vim/.vim/lua/plugins/google.lua | 18 +- vim/.vim/lua/plugins/lsp.lua | 355 ++++++++++++++--------------- vim/.vim/lua/plugins/lsp_lines.lua | 3 +- 4 files changed, 202 insertions(+), 206 deletions(-) diff --git a/vim/.vim/lua/plugins/cmp.lua b/vim/.vim/lua/plugins/cmp.lua index 7eb56f4..3a0eeb8 100644 --- a/vim/.vim/lua/plugins/cmp.lua +++ b/vim/.vim/lua/plugins/cmp.lua @@ -45,7 +45,7 @@ return { local cmp = require("cmp") local conditionalSources = cmp.config.sources({ - { name = "nvim_lsp", priority = 6 }, + { name = "nvim_lsp", priority = 100 }, { name = "nvim_lsp_signature_help", priority = 6 }, { name = "luasnip", priority = 7 }, { name = "calc" }, @@ -69,7 +69,7 @@ return { if use_google() then require("cmp_nvim_ciderlsp").setup() table.insert(conditionalSources, { name = "analysislsp" }) - table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 8 }) + table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 80 }) else table.insert(conditionalSources, { name = "cmp_tabnine" }) end @@ -160,20 +160,18 @@ return { formatting = { format = lspkind.cmp_format({ - with_text = true, - - -- mode = "symbol_text", - -- before = function(entry, vim_item) - -- if entry.source.name == "nvim_ciderlsp" then - -- if entry.completion_item.is_multiline then - -- -- multi-line specific formatting here - -- vim_item.menu = "  " - -- else - -- vim_item.menu = "" - -- end - -- end - -- return vim_item - -- end, + mode = "symbol_text", + before = function(entry, vim_item) + if entry.source.name == "nvim_ciderlsp" then + if entry.completion_item.is_multiline then + -- multi-line specific formatting here + vim_item.menu = "  " + else + vim_item.menu = "" + end + end + return vim_item + end, maxwidth = 50, -- half max width menu = { nvim_ciderlsp = "", @@ -188,8 +186,8 @@ return { }, }), }, - experimental = { + native_menu = false, ghost_text = true, }, }) diff --git a/vim/.vim/lua/plugins/google.lua b/vim/.vim/lua/plugins/google.lua index e4b1752..3df0860 100644 --- a/vim/.vim/lua/plugins/google.lua +++ b/vim/.vim/lua/plugins/google.lua @@ -137,16 +137,18 @@ return { -- Here are all the options and their default values: require("google.comments").setup({ -- command = {'/google/bin/releases/editor-devtools/get_comments.par', '--full', '--json', "-x=''"}, - -- stubby = true, + stubby = true, + -- command = { + -- "/google/bin/releases/editor-devtools/get_comments.par", + -- "--json", + -- "--full", + -- "--noresolved", + -- "--cl_comments", + -- "--file_comments", + -- }, command = { - "/google/bin/releases/editor-devtools/get_comments.par", - "--json", - "--full", - "--noresolved", - "--cl_comments", - "--file_comments", + 'stubby --output_json call blade:codereview-rpc CodereviewRpcService.GetComments "changelist_number: $(/google/data/ro/teams/fig/bin/vcstool pending-change-number)"', }, - -- command = {'stubby --output_json call blade:codereview-rpc CodereviewRpcService.GetComments "changelist_number: $(/google/data/ro/teams/fig/bin/vcstool pending-change-number)"'}, -- Define your own icon by `vim.fn.sign_define('ICON_NAME', {text = ' '})`. -- See :help sign_define -- The sign property passed to setup should be the 'ICON_NAME' in the define diff --git a/vim/.vim/lua/plugins/lsp.lua b/vim/.vim/lua/plugins/lsp.lua index 3254bf1..7d99230 100644 --- a/vim/.vim/lua/plugins/lsp.lua +++ b/vim/.vim/lua/plugins/lsp.lua @@ -1,197 +1,192 @@ return { - { - "neovim/nvim-lspconfig", - -- event = "VimEnter", - dependencies = { - "hrsh7th/nvim-cmp", - "nvim-lua/lsp-status.nvim", - "VonHeikemen/lsp-zero.nvim", - "rcarriga/nvim-notify", - }, - keys = { - { "rn", "lua vim.lsp.buf.rename()" }, - { "ca", "lua vim.lsp.buf.code_action()" }, - { "L", "lua vim.lsp.buf.hover()" }, - { "g0", "lua vim.lsp.buf.document_symbol()" }, - { "gW", "lua vim.lsp.buf.workspace_symbol()" }, - { "gd", "lua vim.lsp.buf.definition()" }, - { "gD", "tab split | lua vim.lsp.buf.definition()" }, - { "gi", "lua vim.lsp.buf.implementation()" }, - { "gI", "lua vim.lsp.buf.implementation()" }, - { "gR", "lua vim.lsp.buf.references()" }, - { "", "lua vim.lsp.buf.signature_help()" }, - { "gt", "lua vim.lsp.buf.type_definition()" }, - { "", "lua vim.lsp.buf.signature_help()", mode = "i" }, - { "ca", "lua vim.lsp.buf.code_action()", mode = "v" }, - }, - config = function() - local use_google = require("utils").use_google - local notify = require("notify") + { + "neovim/nvim-lspconfig", + -- event = "VimEnter", + dependencies = { + "hrsh7th/nvim-cmp", + "nvim-lua/lsp-status.nvim", + "VonHeikemen/lsp-zero.nvim", + "rcarriga/nvim-notify", + }, + keys = { + { "rn", "lua vim.lsp.buf.rename()" }, + { "ca", "lua vim.lsp.buf.code_action()" }, + { "L", "lua vim.lsp.buf.hover()" }, + { "g0", "lua vim.lsp.buf.document_symbol()" }, + { "gW", "lua vim.lsp.buf.workspace_symbol()" }, + { "gd", "lua vim.lsp.buf.definition()" }, + { "gD", "tab split | lua vim.lsp.buf.definition()" }, + { "gi", "lua vim.lsp.buf.implementation()" }, + { "gI", "lua vim.lsp.buf.implementation()" }, + { "gR", "lua vim.lsp.buf.references()" }, + { "", "lua vim.lsp.buf.signature_help()" }, + { "gt", "lua vim.lsp.buf.type_definition()" }, + { "", "lua vim.lsp.buf.signature_help()", mode = "i" }, + { "ca", "lua vim.lsp.buf.code_action()", mode = "v" }, + }, + config = function() + local use_google = require("utils").use_google + local notify = require("notify") - local lspconfig = require("lspconfig") - local configs = require("lspconfig.configs") - local lsp_status = require("lsp-status") - lsp_status.register_progress() + local lspconfig = require("lspconfig") + local configs = require("lspconfig.configs") + local lsp_status = require("lsp-status") + lsp_status.register_progress() - -- CiderLSP - vim.opt.completeopt = { "menu", "menuone", "noselect" } - -- Don't show the dumb matching stuff - vim.opt.shortmess:append("c") + -- Don't show the dumb matching stuff + vim.opt.shortmess:append("c") + vim.opt.completeopt = { "menu", "menuone", "noselect" } - vim.opt.spell = true - vim.opt.spelllang = { "en_us" } - vim.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 + vim.opt.spell = true + vim.opt.spelllang = { "en_us" } + vim.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 - if use_google() then - configs.ciderlsp = { - default_config = { - cmd = { - "/google/bin/releases/cider/ciderlsp/ciderlsp", - "--tooltag=nvim-cmp", - "--forward_sync_responses", - }, - offset_encoding = "utf-8", - filetypes = { - "c", - "cpp", - "java", - "kotlin", - "objc", - "proto", - "textproto", - "go", - "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.ciderlsp = { + default_config = { + cmd = { + "/google/bin/releases/cider/ciderlsp/ciderlsp", + "--tooltag=nvim-lsp", + "--forward_sync_responses", + }, + offset_encoding = "utf-8", + filetypes = { + "c", + "cpp", + "java", + "kotlin", + "objc", + "proto", + "textproto", + "go", + "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 = {}, + }, + } - configs.analysislsp = { - default_config = { - cmd = { - "/google/bin/users/lerm/glint-ale/analysis_lsp/server", - "--lint_on_save=false", - "--max_qps=10", - }, - offset_encoding = "utf-8", - filetypes = { - "c", - "cpp", - "java", - "kotlin", - "objc", - "proto", - "textproto", - "go", - "python", - "bzl", - "markdown", - "typescript", - "javascript", - }, - root_dir = function(fname) - return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$") - end, - settings = {}, - }, - } - end + configs.analysislsp = { + default_config = { + cmd = { + "/google/bin/users/lerm/glint-ale/analysis_lsp/server", + "--lint_on_save=false", + "--max_qps=10", + }, + offset_encoding = "utf-8", + filetypes = { + "c", + "cpp", + "java", + "kotlin", + "objc", + "proto", + "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 = - 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, - } + 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, + } - capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities) + 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) + require("lualine").refresh() - vim.api.nvim_command("autocmd CursorHold lua vim.lsp.buf.document_highlight()") - vim.api.nvim_command("autocmd CursorHoldI lua vim.lsp.buf.document_highlight()") - vim.api.nvim_command("autocmd CursorMoved lua vim.lsp.util.buf_clear_references()") + vim.api.nvim_command("autocmd CursorHold lua vim.lsp.buf.document_highlight()") + vim.api.nvim_command("autocmd CursorHoldI lua vim.lsp.buf.document_highlight()") + vim.api.nvim_command("autocmd CursorMoved lua vim.lsp.util.buf_clear_references()") - 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 + 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 - lsp_status.on_attach(client) - end + lsp_status.on_attach(client) + end - if use_google() then - 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_on_attach = function(client, bufnr) + my_on_attach(client, bufnr) + vim.b["is_cider_lsp_attached"] = "no" + end - local cider_lsp_handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - underline = true, - }), - } + 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["$/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 + require("cmp_nvim_ciderlsp").setup({ + multiline_summary_symbol = "…", + }) + capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities) + capabilities.workspace.codeLens = { refreshSupport = true } + capabilities.workspace.diagnostics = { refreshSupport = true } - capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities) - capabilities.workspace.codeLens = { refreshSupport = true } - capabilities.workspace.diagnostics = { refreshSupport = true } - - lspconfig.analysislsp.setup({ - capabilities = capabilities, - }) - - lspconfig.ciderlsp.setup({ - capabilities = capabilities, - on_attach = cider_on_attach, - handlers = cider_lsp_handlers, - }) - end - end, - }, + lspconfig.ciderlsp.setup({ + capabilities = capabilities, + on_attach = cider_on_attach, + handlers = cider_lsp_handlers, + }) + lspconfig.analysislsp.setup({ + capabilities = capabilities, + }) + end + end, + }, } diff --git a/vim/.vim/lua/plugins/lsp_lines.lua b/vim/.vim/lua/plugins/lsp_lines.lua index 52aaeb3..a84cafb 100644 --- a/vim/.vim/lua/plugins/lsp_lines.lua +++ b/vim/.vim/lua/plugins/lsp_lines.lua @@ -4,7 +4,8 @@ return { lazy = false, config = function() vim.diagnostic.config({ - virtual_lines = { only_current_line = true }, + -- virtual_lines = { only_current_line = true }, + virtual_lines = true, -- update_in_insert = true, virtual_text = false,