From 196c9d1a3bf96088d62d6d02ec62d32c31b198c3 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Tue, 4 Feb 2025 23:09:40 +0000 Subject: [PATCH] simplify google --- vim/.vim/lua/config/lsp-google.lua | 76 ------- vim/.vim/lua/plugins/base.lua | 296 +++++++++++++-------------- vim/.vim/lua/plugins/bufferline.lua | 139 ++++++------- vim/.vim/lua/plugins/lsp.lua | 267 ++++++++++++------------ vim/.vim/lua/plugins/lualine.lua | 119 ++++------- vim/.vim/lua/plugins/telescope.lua | 305 ++++++++++++++-------------- 6 files changed, 544 insertions(+), 658 deletions(-) delete mode 100644 vim/.vim/lua/config/lsp-google.lua diff --git a/vim/.vim/lua/config/lsp-google.lua b/vim/.vim/lua/config/lsp-google.lua deleted file mode 100644 index 936f9bf..0000000 --- a/vim/.vim/lua/config/lsp-google.lua +++ /dev/null @@ -1,76 +0,0 @@ -local use_google = require("utils").use_google -local M = {} - -function M.setup(capabilities) - if use_google() then - local lspconfig = require("lspconfig") - local configs = require("lspconfig.configs") - configs.ciderlsp = { - default_config = { - -- offset_encoding = "utf-16", - cmd = { - "/google/bin/releases/cider/ciderlsp/ciderlsp", - "--tooltag=nvim-lsp", - "--forward_sync_responses", - -- "--debug_relay", - }, - filetypes = { - "c", - "cpp", - "java", - "kotlin", - "objc", - "proto", - "textproto", - "go", - "python", - "bzl", - "typescript", - }, - root_dir = require("lspconfig").util.root_pattern(".citc"), - settings = {}, - }, - } - - local my_on_attach = function(client, bufnr) - 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 - - local lsp_status = require("lsp-status") - lsp_status.on_attach(client) - end - - local cider_on_attach = function(client, bufnr) - my_on_attach(client, bufnr) - vim.b["is_cider_lsp_attached"] = "no" - end - - local cider_lsp_handlers = {} - -- cider_lsp_handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - -- focusable = false, - -- }) - - cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx) - local first_fire = vim.b["is_cider_lsp_attached"] == "no" - vim.b["is_cider_lsp_attached"] = "yes" - if first_fire then - vim.notify("CiderLSP attached") - require("lualine").refresh() - end - end - - lspconfig.ciderlsp.setup({ - capabilities = capabilities, - on_attach = cider_on_attach, - handlers = cider_lsp_handlers, - }) - end -end - -return M diff --git a/vim/.vim/lua/plugins/base.lua b/vim/.vim/lua/plugins/base.lua index d269272..a5c3286 100644 --- a/vim/.vim/lua/plugins/base.lua +++ b/vim/.vim/lua/plugins/base.lua @@ -1,18 +1,18 @@ local use_google = require("utils").use_google return { - "sindrets/diffview.nvim", - --{ "mizlan/iswap.nvim", event = "VeryLazy" }, - { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, - { - "folke/flash.nvim", - event = "VeryLazy", - ---@type Flash.Config - opts = { - jump = { - nohlsearch = true, - }, - }, + "sindrets/diffview.nvim", + --{ "mizlan/iswap.nvim", event = "VeryLazy" }, + { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, + { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = { + jump = { + nohlsearch = true, + }, + }, -- stylua: ignore keys = { { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, @@ -21,156 +21,146 @@ return { { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, - }, - { - "MagicDuck/grug-far.nvim", - config = function() - vim.g.maplocalleader = "," - require("grug-far").setup({ - -- search and replace engines configuration - engines = { - -- see https://github.com/BurntSushi/ripgrep - ripgrep = { - -- ripgrep executable to use, can be a different path if you need to configure - path = "rg", - -- extraArgs = "-.", - }, - }, - }) - end, - }, + }, + { + "MagicDuck/grug-far.nvim", + config = function() + vim.g.maplocalleader = "," + require("grug-far").setup({ + -- search and replace engines configuration + engines = { + -- see https://github.com/BurntSushi/ripgrep + ripgrep = { + -- ripgrep executable to use, can be a different path if you need to configure + path = "rg", + -- extraArgs = "-.", + }, + }, + }) + end, + }, - { - "shellRaining/hlchunk.nvim", - event = { "BufReadPre", "BufNewFile" }, - opts = { - line_num = { enable = true }, - chunk = { - enable = true, - priority = 15, - style = { - { fg = "#393d4c" }, - }, - chars = { - horizontal_line = "─", - -- vertical_line = "│", - vertical_line = "┊", - left_top = "╭", - left_bottom = "╰", - right_arrow = ">", - }, - use_treesitter = true, - textobject = "", - max_file_size = 1024 * 1024, - error_sign = true, - -- animation related - duration = 0, - delay = 0, - }, - }, - }, - { - "Bekaboo/dropbar.nvim", - -- optional, but required for fuzzy finder support - dependencies = { - "nvim-telescope/telescope-fzf-native.nvim", - }, - config = function() - vim.ui.select = require("dropbar.utils.menu").select - end, - }, - "RRethy/vim-illuminate", - "kdheepak/lazygit.nvim", - "flwyd/vim-conjoin", - "rafcamlet/nvim-luapad", - "vim-scripts/vcscommand.vim", - "AndrewRadev/tagalong.vim", - "AndrewRadev/yankwin.vim", - { "squk/gdrama-syntax.vim", ft = "gdrama" }, - { "nvim-lua/plenary.nvim", lazy = false }, - { "squk/java-syntax.vim", ft = "java" }, - { "udalov/kotlin-vim", event = "VeryLazy", ft = "kotlin" }, - -- { "andymass/vim-matchup", event = "VimEnter" }, - { "jghauser/mkdir.nvim", event = "BufWritePre" }, - { - "rmagatti/auto-session", - dependencies = { - "nvim-telescope/telescope.nvim", -- Only needed if you want to use session lens - }, - config = function() - require("auto-session").setup({ - auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" }, - args_allow_single_directory = false, - bypass_save_filetypes = { "netrw" }, - }) - end, - }, - "tpope/vim-abolish", - { - "johmsalas/text-case.nvim", - dependencies = { "nvim-telescope/telescope.nvim" }, - config = function() - require("textcase").setup({}) - require("telescope").load_extension("textcase") - end, - cmd = { - "Subs", - }, + { + "shellRaining/hlchunk.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + line_num = { enable = true }, + chunk = { + enable = true, + priority = 15, + style = { + { fg = "#393d4c" }, + }, + chars = { + horizontal_line = "─", + -- vertical_line = "│", + vertical_line = "┊", + left_top = "╭", + left_bottom = "╰", + right_arrow = ">", + }, + use_treesitter = true, + textobject = "", + max_file_size = 1024 * 1024, + error_sign = true, + -- animation related + duration = 0, + delay = 0, + }, + }, + }, + "RRethy/vim-illuminate", + "kdheepak/lazygit.nvim", + "flwyd/vim-conjoin", + "rafcamlet/nvim-luapad", + "vim-scripts/vcscommand.vim", + "AndrewRadev/tagalong.vim", + "AndrewRadev/yankwin.vim", + { "squk/gdrama-syntax.vim", ft = "gdrama" }, + { "nvim-lua/plenary.nvim", lazy = false }, + { "squk/java-syntax.vim", ft = "java" }, + { "udalov/kotlin-vim", event = "VeryLazy", ft = "kotlin" }, + { "andymass/vim-matchup", event = "VimEnter" }, + { "jghauser/mkdir.nvim", event = "BufWritePre" }, + { + "rmagatti/auto-session", + dependencies = { + "nvim-telescope/telescope.nvim", -- Only needed if you want to use session lens + }, + config = function() + require("auto-session").setup({ + auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" }, + args_allow_single_directory = false, + bypass_save_filetypes = { "netrw" }, + }) + end, + }, + "tpope/vim-abolish", + { + "johmsalas/text-case.nvim", + dependencies = { "nvim-telescope/telescope.nvim" }, + config = function() + require("textcase").setup({}) + require("telescope").load_extension("textcase") + end, + cmd = { + "Subs", + }, -- stylua: ignore keys = { { "tc", "TextCaseOpenTelescope", mode = { "n", "v" }, desc = "Telescope" }, }, - }, - { - "NvChad/nvim-colorizer.lua", - ft = "lua", - config = function() - require("colorizer").setup() - end, - }, - { + }, + { + "NvChad/nvim-colorizer.lua", + ft = "lua", + config = function() + require("colorizer").setup() + end, + }, + { - "andweeb/presence.nvim", - cond = not use_google(), - config = function() - require("presence").setup({ - main_image = "file", - show_time = false, - }) - end, - }, - { - "ntpeters/vim-better-whitespace", - config = function() - vim.g.better_whitespace_filetypes_blacklist = { "dashboard" } - end, - }, - { - "mbbill/undotree", - cmd = "UndotreeToggle", - config = function() - vim.g.undotree_SetFocusWhenToggle = 1 - end, + "andweeb/presence.nvim", + cond = not use_google(), + config = function() + require("presence").setup({ + main_image = "file", + show_time = false, + }) + end, + }, + { + "ntpeters/vim-better-whitespace", + config = function() + vim.g.better_whitespace_filetypes_blacklist = { "dashboard" } + end, + }, + { + "mbbill/undotree", + cmd = "UndotreeToggle", + config = function() + vim.g.undotree_SetFocusWhenToggle = 1 + end, -- stylua: ignore keys = { { "ut", ":UndotreeToggle" } }, - }, - { - "stevearc/aerial.nvim", - opts = {}, - cmd = { "AerialToggle", "AerialOn" }, + }, + { + "stevearc/aerial.nvim", + opts = {}, + cmd = { "AerialToggle", "AerialOn" }, -- stylua: ignore keys = { { "so", ":AerialToggle", desc = "[S]symbols [O]utline" } }, - }, - { - "andrewferrier/debugprint.nvim", - opts = {}, - -- Dependency only needed for NeoVim 0.8 - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, - -- Remove the following line to use development versions, - -- not just the formal releases - version = "*", + }, + { + "andrewferrier/debugprint.nvim", + opts = {}, + -- Dependency only needed for NeoVim 0.8 + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + -- Remove the following line to use development versions, + -- not just the formal releases + version = "*", -- stylua: ignore keys = { { "dp", ":lua require('debugprint').debugprint()", desc = "Debug print" }, @@ -178,5 +168,5 @@ return { { "dq", ":lua require('debugprint').debugprint({variable = true})", desc = "Debug print" }, { "dQ", ":lua require('debugprint').debugprint({variable = true, above = true})", desc = "Debug print", }, }, - }, + }, } diff --git a/vim/.vim/lua/plugins/bufferline.lua b/vim/.vim/lua/plugins/bufferline.lua index 1aec3d9..b8596cd 100644 --- a/vim/.vim/lua/plugins/bufferline.lua +++ b/vim/.vim/lua/plugins/bufferline.lua @@ -1,71 +1,72 @@ return { - { - "akinsho/bufferline.nvim", - version = "*", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - options = { - hover = { - enabled = true, - delay = 200, - reveal = { "close" }, - }, - indicator = { - -- icon = "▎", -- this should be omitted if indicator style is not 'icon' - style = "icon", -- | 'underline' | 'none', - }, - offsets = { - { - filetype = "NvimTree", - text = "File Explorer", - highlight = "Directory", - separator = true, -- use a "true" to enable the default, or set your own character - }, - }, - mode = "tabs", - diagnostics = "nvim_lsp", - diagnostics_indicator = function(count, level, diagnostics_dict, context) - local symbols = { error = " ", warning = " ", info = " ", hint = "󱠂 " } - local icon = symbols[level] or level - return "" .. icon .. count - end, - max_name_length = 30, - truncate_name = false, - show_close_icon = false, - show_buffer_close_icons = false, - -- groups = { - -- options = { - -- toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible - -- }, - -- items = { - -- { - -- name = "Tests", -- Mandatory - -- highlight = { sp = "lightblue" }, -- Optional - -- priority = 2, -- determines where it will appear relative to other groups (Optional) - -- icon = " ", -- Optional - -- matcher = function(buf) -- Mandatory - -- return buf.path:match("%_test.cc$") or buf.path:match("%Test.java$") - -- end, - -- }, - -- { - -- name = "Docs", - -- highlight = { sp = "lightgreen" }, - -- auto_close = false, -- whether or not close this group if it doesn't contain the current buffer - -- matcher = function(buf) - -- return buf.path:match("%.md$") or buf.path:match("%.txt$") - -- end, - -- }, - -- { - -- name = "Lua", - -- highlight = { sp = "lightblue" }, - -- auto_close = false, -- whether or not close this group if it doesn't contain the current buffer - -- matcher = function(buf) - -- return buf.path:match("%.lua$") - -- end, - -- }, - -- }, - -- }, - }, - }, - }, + { + "akinsho/bufferline.nvim", + version = "*", + cond = false, + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + options = { + hover = { + enabled = true, + delay = 200, + reveal = { "close" }, + }, + indicator = { + -- icon = "▎", -- this should be omitted if indicator style is not 'icon' + style = "icon", -- | 'underline' | 'none', + }, + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + highlight = "Directory", + separator = true, -- use a "true" to enable the default, or set your own character + }, + }, + -- mode = "tabs", + diagnostics = "nvim_lsp", + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local symbols = { error = " ", warning = " ", info = " ", hint = "󱠂 " } + local icon = symbols[level] or level + return "" .. icon .. count + end, + max_name_length = 30, + truncate_name = false, + show_close_icon = false, + show_buffer_close_icons = false, + groups = { + options = { + toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible + }, + items = { + { + name = "Tests", -- Mandatory + highlight = { sp = "lightblue" }, -- Optional + priority = 2, -- determines where it will appear relative to other groups (Optional) + icon = " ", -- Optional + matcher = function(buf) -- Mandatory + return buf.path:match("%_test.cc$") or buf.path:match("%Test.java$") + end, + }, + { + name = "Docs", + highlight = { sp = "lightgreen" }, + auto_close = false, -- whether or not close this group if it doesn't contain the current buffer + matcher = function(buf) + return buf.path:match("%.md$") or buf.path:match("%.txt$") + end, + }, + { + name = "Lua", + highlight = { sp = "lightblue" }, + auto_close = false, -- whether or not close this group if it doesn't contain the current buffer + matcher = function(buf) + return buf.path:match("%.lua$") + end, + }, + }, + }, + }, + }, + }, } diff --git a/vim/.vim/lua/plugins/lsp.lua b/vim/.vim/lua/plugins/lsp.lua index 0285b58..5b08748 100644 --- a/vim/.vim/lua/plugins/lsp.lua +++ b/vim/.vim/lua/plugins/lsp.lua @@ -2,135 +2,148 @@ local use_google = require("utils").use_google local flags = require("utils").flags return { - -- { - -- "ray-x/lsp_signature.nvim", - -- event = "VeryLazy", - -- opts = { - -- floating_window = true, - -- hint_prefix = "󰡱 ", - -- }, - -- config = function(_, opts) - -- require("lsp_signature").setup(opts) - -- end, - -- }, - { - "kosayoda/nvim-lightbulb", - commit = "1cae7b7153ae98dcf1b11173a443ac1b6d8e3d49", - event = { "LspAttach" }, - opts = { - autocmd = { enabled = true }, - virtual_text = { - enabled = true, - text = " 󱐋", - hl = "DiagnosticWarn", - }, - sign = { enabled = false }, - }, - }, - { - "L3MON4D3/LuaSnip", - build = "make install_jsregexp", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - dependencies = { "rafamadriz/friendly-snippets" }, - }, - { - "hinell/lsp-timeout.nvim", - event = { "LspAttach" }, - dependencies = { "neovim/nvim-lspconfig" }, - -- cond = not use_google(), - config = function() - vim.g.lspTimeoutConfig = { - filetypes = { - ignore = { -- filetypes to ignore; empty by default - "gdscript", - "rust", - }, -- for these filetypes - }, - } - end, - }, - { - "ray-x/go.nvim", - dependencies = { -- optional packages - "ray-x/guihua.lua", - "neovim/nvim-lspconfig", - "nvim-treesitter/nvim-treesitter", - }, - -- cond = not use_google(), - config = function() - local capabilities = flags.blink - and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) - or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) - capabilities.offsetEncoding = { "utf-16" } - require("go").setup({ - lsp_cfg = { capabilities = capabilities }, - lsp_keymaps = false, - lsp_inlay_hints = { - enable = not use_google(), -- doesn't work with ciderlsp - }, - }) - -- Run gofmt + goimports on save + -- { + -- "ray-x/lsp_signature.nvim", + -- event = "VeryLazy", + -- opts = { + -- floating_window = true, + -- hint_prefix = "󰡱 ", + -- }, + -- config = function(_, opts) + -- require("lsp_signature").setup(opts) + -- end, + -- }, + { + "kosayoda/nvim-lightbulb", + commit = "1cae7b7153ae98dcf1b11173a443ac1b6d8e3d49", + event = { "LspAttach" }, + opts = { + autocmd = { enabled = true }, + virtual_text = { + enabled = true, + text = " 󱐋", + hl = "DiagnosticWarn", + }, + sign = { enabled = false }, + }, + }, + { + "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + dependencies = { "rafamadriz/friendly-snippets" }, + }, + { + "hinell/lsp-timeout.nvim", + event = { "LspAttach" }, + dependencies = { "neovim/nvim-lspconfig" }, + -- cond = not use_google(), + config = function() + vim.g.lspTimeoutConfig = { + filetypes = { + ignore = { -- filetypes to ignore; empty by default + "gdscript", + "rust", + }, -- for these filetypes + }, + } + end, + }, + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + -- cond = not use_google(), + config = function() + local capabilities = flags.blink + and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) + or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + capabilities.offsetEncoding = { "utf-16" } + require("go").setup({ + lsp_cfg = { capabilities = capabilities }, + lsp_keymaps = false, + lsp_inlay_hints = { + enable = not use_google(), -- doesn't work with ciderlsp + }, + }) + -- Run gofmt + goimports on save - local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) - vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*.go", - callback = function() - require("go.format").goimports() - end, - group = format_sync_grp, - }) - end, - ft = { "go", "gomod" }, - build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries - }, - { - "neovim/nvim-lspconfig", - dependencies = { - "hrsh7th/nvim-cmp", - "saghen/blink.cmp", - "saghen/blink.compat", - "nvim-lua/lsp-status.nvim", - "VonHeikemen/lsp-zero.nvim", - }, - keys = { - { "F", ":lua vim.lsp.buf.format()" }, - { "rn", ":lua vim.lsp.buf.rename()" }, - { "L", ":lua vim.lsp.buf.hover()" }, - { "gr", ":Telescope lsp_references" }, - { "gd", ":lua vim.lsp.buf.definition()" }, - -- { "gd", "Telescope lsp_definitions" }, - { "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()" }, - { "gt", ":lua vim.lsp.buf.type_definition()" }, - { "", ":lua vim.lsp.buf.signature_help()" }, - { "", ":lua vim.lsp.buf.signature_help()", mode = "i" }, - }, - config = function() - local lsp_status = require("lsp-status") - lsp_status.register_progress() + local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, + }) + end, + ft = { "go", "gomod" }, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries + }, + { + "neovim/nvim-lspconfig", + dependencies = { + "hrsh7th/nvim-cmp", + "saghen/blink.cmp", + "saghen/blink.compat", + "nvim-lua/lsp-status.nvim", + "VonHeikemen/lsp-zero.nvim", + }, + keys = { + { "F", ":lua vim.lsp.buf.format()" }, + { "rn", ":lua vim.lsp.buf.rename()" }, + { "L", ":lua vim.lsp.buf.hover()" }, + { "gr", ":Telescope lsp_references" }, + { "gd", ":lua vim.lsp.buf.definition()" }, + -- { "gd", "Telescope lsp_definitions" }, + { "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()" }, + { "gt", ":lua vim.lsp.buf.type_definition()" }, + { "", ":lua vim.lsp.buf.signature_help()" }, + { "", ":lua vim.lsp.buf.signature_help()", mode = "i" }, + }, + config = function() + local lsp_status = require("lsp-status") + lsp_status.register_progress() - local capabilities = flags.blink - and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) - or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) - capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities) - capabilities.offsetEncoding = { "utf-16" } + local capabilities = flags.blink + and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) + or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities) + capabilities.offsetEncoding = { "utf-16" } - local lspconfig = require("lspconfig") - local configs = require("lspconfig.configs") - require("config.lsp-google").setup(capabilities) + local lspconfig = require("lspconfig") + local configs = require("lspconfig.configs") - -- Godot - lspconfig.gdscript.setup({ - -- flags = { - -- debounce_text_changes = 2000, -- Wait 5 seconds before sending didChange - -- }, - }) - vim.cmd([[autocmd FileType gdscript setlocal commentstring=#\ %s]]) - vim.cmd([[autocmd FileType gdscript setlocal autoindent noexpandtab tabstop=4 shiftwidth=4]]) - end, - }, + local nvim_lspconfig = require("lspconfig") + local lsp_configs = require("lspconfig.configs") + + lsp_configs.ciderlsp = { + default_config = { + cmd = { '/google/bin/releases/cider/ciderlsp/ciderlsp', '--tooltag=nvim-lsp', '--noforward_sync_responses' }, + filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl", "typescript" }, + offset_encoding = 'utf-8', + root_dir = nvim_lspconfig.util.root_pattern('.citc'), + settings = {}, + } + } + + nvim_lspconfig.ciderlsp.setup {} + -- Godot + lspconfig.gdscript.setup({ + -- flags = { + -- debounce_text_changes = 2000, -- Wait 5 seconds before sending didChange + -- }, + }) + vim.cmd([[autocmd FileType gdscript setlocal commentstring=#\ %s]]) + vim.cmd([[autocmd FileType gdscript setlocal autoindent noexpandtab tabstop=4 shiftwidth=4]]) + end, + }, } diff --git a/vim/.vim/lua/plugins/lualine.lua b/vim/.vim/lua/plugins/lualine.lua index bf20940..ce9faf9 100644 --- a/vim/.vim/lua/plugins/lualine.lua +++ b/vim/.vim/lua/plugins/lualine.lua @@ -1,84 +1,41 @@ -local split = function(inputstr, sep) - local t = {} - for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do - table.insert(t, str) - end - return t -end -local function getCitc() - local fname = vim.api.nvim_buf_get_name(0) - if string.find(fname, "/google/src/cloud/", 1, true) then - local parts = split(fname, "/") - return parts[5] - end -end -local function isCiderLspAttached() - if vim.b["is_cider_lsp_attached"] then - if vim.b["is_cider_lsp_attached"] == "yes" then - return "✓" - else - return "x" - end - else - return "" - end -end - -local function getLightbulb() - return require("nvim-lightbulb").get_status_text() -end - -local function getLGTMs() - local comments = require("google.comments") - local tracker = require("google.comments.tracker") - local dump = require("utils").dump - - print(dump(tracker.get_all_comments())) - local lgtm = comments.get_lgtms() - local appr = comments.get_approvals() - print("lgtms" .. dump(lgtm)) - print("approvals" .. dump(appr)) - return "LGTM:" .. table.concat(lgtm, ",") .. " Approval:" .. table.concat(appr, ",") -end - return { - "nvim-lualine/lualine.nvim", - lazy = false, - config = function() - local lsp_status = require("lsp-status") + "nvim-lualine/lualine.nvim", + lazy = false, + config = function() + local lsp_status = require("lsp-status") - require("lualine").setup({ - options = { - theme = "auto", - globalstatus = false, - refresh = { - statusline = 1000, - -- tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "branch", "diff", getCitc, isCiderLspAttached }, - lualine_c = { - getLightbulb, - { - "filename", - path = 4, -- 0 = just filename, 1 = relative path, 2 = absolute path - }, - }, - lualine_x = { - "", - { - "diagnostics", - sources = { "nvim_lsp" }, - symbols = { error = " ", warn = " ", info = " ", hint = " " }, - }, - "filetype", - }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - }) - end, + require("lualine").setup({ + options = { + theme = "auto", + globalstatus = false, + refresh = { + statusline = 100, + tabline = 100, + winbar = 100, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff" }, + lualine_c = { + require("nvim-lightbulb").get_status_text, + { + "filename", + path = 4, -- 0 = just filename, 1 = relative path, 2 = absolute path + }, + }, + lualine_x = { + "", + { + "diagnostics", + sources = { "nvim_lsp" }, + symbols = { error = " ", warn = " ", info = " ", hint = " " }, + }, + "filetype", + }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + }) + end, } diff --git a/vim/.vim/lua/plugins/telescope.lua b/vim/.vim/lua/plugins/telescope.lua index 8631953..be22357 100644 --- a/vim/.vim/lua/plugins/telescope.lua +++ b/vim/.vim/lua/plugins/telescope.lua @@ -3,43 +3,44 @@ local exec = require("utils").exec local TableConcat = require("utils").TableConcat _G.find_files = function(search_dirs) - require("telescope.builtin").find_files({ search_dirs = search_dirs }) + require("telescope.builtin").find_files({ search_dirs = search_dirs }) end -- Helper functions to fetch the current scope and set `search_dirs` _G.find_dotfiles = function() end _G.search_cwd = function() - local builtin = require("telescope.builtin") - local utils = require("telescope.utils") - builtin.find_files({ cwd = utils.buffer_dir() }) + local builtin = require("telescope.builtin") + local utils = require("telescope.utils") + builtin.find_files({ cwd = utils.buffer_dir() }) end _G.live_grep = function(search_dirs) - require("telescope.builtin").live_grep({ - search_dirs = search_dirs, - }) + require("telescope.builtin").live_grep({ + search_dirs = search_dirs, + }) end _G.live_grep_cword = function(search_dirs) - require("telescope.builtin").live_grep({ search_dirs = search_dirs }) + require("telescope.builtin").live_grep({ search_dirs = search_dirs }) end local function exe(cmd) - return vim.split(vim.fn.system(cmd), "\n") + return vim.split(vim.fn.system(cmd), "\n") end function fig_modified() - return exe("hg pstatus -ma -n --no-status --template= | sort") + return exe("hg pstatus -ma -n --no-status --template= | sort") end function fig_all_modified() - return exe("hg status -ma -n --rev p4base --no-status --template= | sort") + return exe("hg status -ma -n --rev p4base --no-status --template= | sort") end -- stylua: ignore local keys = { -- { "e", ":lua search_cwd()", desc = "Find Files in Buffer Directory" }, { "ts", require('telescope.builtin').live_grep }, + { "tb", ":Telescope buffers" }, { "TS", function() require('telescope.builtin').live_grep { default_text = vim.fn.expand("") } end, }, { "t.", @@ -61,8 +62,8 @@ local keys = { } if use_google() then - local find_files = require("telescope.builtin").find_files - local cs_query = require("telescope").extensions.codesearch.find_query + local find_files = require("telescope.builtin").find_files + local cs_query = require("telescope").extensions.codesearch.find_query -- stylua: ignore TableConcat(keys, { { "tm", function() find_files({ search_dirs = fig_modified() }) end, desc = "list modified Fig files." }, @@ -77,144 +78,144 @@ if use_google() then end return { - { - "aznhe21/actions-preview.nvim", - config = function() - require("actions-preview").setup({ - telescope = { - sorting_strategy = "ascending", - layout_strategy = "vertical", - layout_config = { - width = 0.8, - height = 0.9, - prompt_position = "top", - preview_cutoff = 20, - preview_height = function(_, _, max_lines) - return max_lines - 15 - end, - }, - }, - }) - end, - keys = { - { "?", "lua require('actions-preview').code_actions()" }, - }, - }, - { - "smartpde/telescope-recent-files", - config = function() - require("telescope").load_extension("recent_files") - end, - keys = { - { "to", [[lua require('telescope').extensions.recent_files.pick()]] }, - }, - }, - { - "piersolenski/telescope-import.nvim", - dependencies = "nvim-telescope/telescope.nvim", - config = function() - require("telescope").load_extension("import") - end, - keys = function() - if not use_google() then - return { - { "i", ":Telescope import" }, - } - end - end, - }, - { - "nvim-telescope/telescope.nvim", - dependencies = { - "mfussenegger/nvim-dap", - "smartpde/telescope-recent-files", - "rcarriga/nvim-dap-ui", - }, - config = function() - require("telescope").setup({ - defaults = { - -- The vertical layout strategy is good to handle long paths like those in - -- google3 repos because you have nearly the full screen to display a file path. - -- The caveat is that the preview area is smaller. - layout_strategy = "vertical", - -- Common paths in google3 repos are collapsed following the example of Cider - -- It is nice to keep this as a user config rather than part of - -- telescope-codesearch because it can be reused by other telescope pickers. - path_display = function(opts, path) - -- Do common substitutions - path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1) - path = path:gsub("^google3/java/com/google/", "//j/c/g/", 1) - path = path:gsub("^google3/javatests/com/google/", "//jt/c/g/", 1) - path = path:gsub("^google3/third_party/", "//3p/", 1) - path = path:gsub("^google3/", "//", 1) + { + "aznhe21/actions-preview.nvim", + config = function() + require("actions-preview").setup({ + telescope = { + sorting_strategy = "ascending", + layout_strategy = "vertical", + layout_config = { + width = 0.8, + height = 0.9, + prompt_position = "top", + preview_cutoff = 20, + preview_height = function(_, _, max_lines) + return max_lines - 15 + end, + }, + }, + }) + end, + keys = { + { "?", "lua require('actions-preview').code_actions()" }, + }, + }, + { + "smartpde/telescope-recent-files", + config = function() + require("telescope").load_extension("recent_files") + end, + keys = { + { "to", [[lua require('telescope').extensions.recent_files.pick()]] }, + }, + }, + { + "piersolenski/telescope-import.nvim", + dependencies = "nvim-telescope/telescope.nvim", + config = function() + require("telescope").load_extension("import") + end, + keys = function() + if not use_google() then + return { + { "i", ":Telescope import" }, + } + end + end, + }, + { + "nvim-telescope/telescope.nvim", + dependencies = { + "mfussenegger/nvim-dap", + "smartpde/telescope-recent-files", + "rcarriga/nvim-dap-ui", + }, + config = function() + require("telescope").setup({ + defaults = { + -- The vertical layout strategy is good to handle long paths like those in + -- google3 repos because you have nearly the full screen to display a file path. + -- The caveat is that the preview area is smaller. + layout_strategy = "vertical", + -- Common paths in google3 repos are collapsed following the example of Cider + -- It is nice to keep this as a user config rather than part of + -- telescope-codesearch because it can be reused by other telescope pickers. + path_display = function(opts, path) + -- Do common substitutions + path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1) + path = path:gsub("^google3/java/com/google/", "//j/c/g/", 1) + path = path:gsub("^google3/javatests/com/google/", "//jt/c/g/", 1) + path = path:gsub("^google3/third_party/", "//3p/", 1) + path = path:gsub("^google3/", "//", 1) - -- Do truncation. This allows us to combine our custom display formatter - -- with the built-in truncation. - -- `truncate` handler in transform_path memoizes computed truncation length in opts.__length. - -- Here we are manually propagating this value between new_opts and opts. - -- We can make this cleaner and more complicated using metatables :) - local new_opts = { - path_display = { - truncate = true, - }, - __length = opts.__length, - } - path = require("telescope.utils").transform_path(new_opts, path) - opts.__length = new_opts.__length - return path - end, - mappings = { - n = { - [""] = "close", - [""] = "close", - }, - i = { - -- [""] = function(bufnr) - -- require("telescope.actions.set").edit(bufnr, "tab drop") - -- end, - [""] = "close", - [""] = "close", - [""] = "cycle_history_next", - [""] = "cycle_history_prev", - }, - }, - }, - extensions = { - codesearch = { - experimental = true, -- enable results from google3/experimental - }, - recent_files = { - -- This function rewrites all file paths to the current workspace. - -- For example, if w2 is the current workspace, then - -- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc, - transform_file_path = function(path) - local neocitc = require("neocitc") - local path_func = neocitc.path_in_current_workspace_or_head - or neocitc.path_in_current_workspace - return path_func(path) - end, - -- This is a useful option to speed up Telescope by avoiding the check - -- for file existence. - stat_files = false, - -- Ignore common patterns that can show up from other google plugins - ignore_patterns = { - "/%.git/COMMIT_EDITING$", - "/%.git/COMMIT_EDITMSG$", - "/%.git/MERGE_MSG$", - "^/tmp/%.pipertmp-", - "/Related_Files$", - "^term:", - ";#toggleterm#", - }, - }, - persisted = {}, - import = { - -- Add imports to the top of the file keeping the cursor in place - insert_at_top = true, - }, - }, - }) - end, - keys = keys, - }, + -- Do truncation. This allows us to combine our custom display formatter + -- with the built-in truncation. + -- `truncate` handler in transform_path memoizes computed truncation length in opts.__length. + -- Here we are manually propagating this value between new_opts and opts. + -- We can make this cleaner and more complicated using metatables :) + local new_opts = { + path_display = { + truncate = true, + }, + __length = opts.__length, + } + path = require("telescope.utils").transform_path(new_opts, path) + opts.__length = new_opts.__length + return path + end, + mappings = { + n = { + [""] = "close", + [""] = "close", + }, + i = { + -- [""] = function(bufnr) + -- require("telescope.actions.set").edit(bufnr, "tab drop") + -- end, + [""] = "close", + [""] = "close", + [""] = "cycle_history_next", + [""] = "cycle_history_prev", + }, + }, + }, + extensions = { + codesearch = { + experimental = true, -- enable results from google3/experimental + }, + recent_files = { + -- This function rewrites all file paths to the current workspace. + -- For example, if w2 is the current workspace, then + -- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc, + transform_file_path = function(path) + local neocitc = require("neocitc") + local path_func = neocitc.path_in_current_workspace_or_head + or neocitc.path_in_current_workspace + return path_func(path) + end, + -- This is a useful option to speed up Telescope by avoiding the check + -- for file existence. + stat_files = false, + -- Ignore common patterns that can show up from other google plugins + ignore_patterns = { + "/%.git/COMMIT_EDITING$", + "/%.git/COMMIT_EDITMSG$", + "/%.git/MERGE_MSG$", + "^/tmp/%.pipertmp-", + "/Related_Files$", + "^term:", + ";#toggleterm#", + }, + }, + persisted = {}, + import = { + -- Add imports to the top of the file keeping the cursor in place + insert_at_top = true, + }, + }, + }) + end, + keys = keys, + }, }