simplify google

This commit is contained in:
Christian Nieves
2025-02-04 23:09:40 +00:00
parent 9988bd13b2
commit 196c9d1a3b
6 changed files with 544 additions and 658 deletions

View File

@ -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

View File

@ -69,16 +69,6 @@ return {
}, },
}, },
}, },
{
"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", "RRethy/vim-illuminate",
"kdheepak/lazygit.nvim", "kdheepak/lazygit.nvim",
"flwyd/vim-conjoin", "flwyd/vim-conjoin",
@ -90,7 +80,7 @@ return {
{ "nvim-lua/plenary.nvim", lazy = false }, { "nvim-lua/plenary.nvim", lazy = false },
{ "squk/java-syntax.vim", ft = "java" }, { "squk/java-syntax.vim", ft = "java" },
{ "udalov/kotlin-vim", event = "VeryLazy", ft = "kotlin" }, { "udalov/kotlin-vim", event = "VeryLazy", ft = "kotlin" },
-- { "andymass/vim-matchup", event = "VimEnter" }, { "andymass/vim-matchup", event = "VimEnter" },
{ "jghauser/mkdir.nvim", event = "BufWritePre" }, { "jghauser/mkdir.nvim", event = "BufWritePre" },
{ {
"rmagatti/auto-session", "rmagatti/auto-session",

View File

@ -2,6 +2,7 @@ return {
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
version = "*", version = "*",
cond = false,
dependencies = { "nvim-tree/nvim-web-devicons" }, dependencies = { "nvim-tree/nvim-web-devicons" },
opts = { opts = {
options = { options = {
@ -22,7 +23,7 @@ return {
separator = true, -- use a "true" to enable the default, or set your own character separator = true, -- use a "true" to enable the default, or set your own character
}, },
}, },
mode = "tabs", -- mode = "tabs",
diagnostics = "nvim_lsp", diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context) diagnostics_indicator = function(count, level, diagnostics_dict, context)
local symbols = { error = "", warning = "", info = "", hint = "󱠂 " } local symbols = { error = "", warning = "", info = "", hint = "󱠂 " }
@ -33,38 +34,38 @@ return {
truncate_name = false, truncate_name = false,
show_close_icon = false, show_close_icon = false,
show_buffer_close_icons = false, show_buffer_close_icons = false,
-- groups = { groups = {
-- options = { options = {
-- toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible
-- }, },
-- items = { items = {
-- { {
-- name = "Tests", -- Mandatory name = "Tests", -- Mandatory
-- highlight = { sp = "lightblue" }, -- Optional highlight = { sp = "lightblue" }, -- Optional
-- priority = 2, -- determines where it will appear relative to other groups (Optional) priority = 2, -- determines where it will appear relative to other groups (Optional)
-- icon = " ", -- Optional icon = "", -- Optional
-- matcher = function(buf) -- Mandatory matcher = function(buf) -- Mandatory
-- return buf.path:match("%_test.cc$") or buf.path:match("%Test.java$") return buf.path:match("%_test.cc$") or buf.path:match("%Test.java$")
-- end, end,
-- }, },
-- { {
-- name = "Docs", name = "Docs",
-- highlight = { sp = "lightgreen" }, highlight = { sp = "lightgreen" },
-- auto_close = false, -- whether or not close this group if it doesn't contain the current buffer auto_close = false, -- whether or not close this group if it doesn't contain the current buffer
-- matcher = function(buf) matcher = function(buf)
-- return buf.path:match("%.md$") or buf.path:match("%.txt$") return buf.path:match("%.md$") or buf.path:match("%.txt$")
-- end, end,
-- }, },
-- { {
-- name = "Lua", name = "Lua",
-- highlight = { sp = "lightblue" }, highlight = { sp = "lightblue" },
-- auto_close = false, -- whether or not close this group if it doesn't contain the current buffer auto_close = false, -- whether or not close this group if it doesn't contain the current buffer
-- matcher = function(buf) matcher = function(buf)
-- return buf.path:match("%.lua$") return buf.path:match("%.lua$")
-- end, end,
-- }, },
-- }, },
-- }, },
}, },
}, },
}, },

View File

@ -121,8 +121,21 @@ return {
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs") local configs = require("lspconfig.configs")
require("config.lsp-google").setup(capabilities)
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 -- Godot
lspconfig.gdscript.setup({ lspconfig.gdscript.setup({
-- flags = { -- flags = {

View File

@ -1,46 +1,3 @@
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 { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
lazy = false, lazy = false,
@ -52,16 +9,16 @@ return {
theme = "auto", theme = "auto",
globalstatus = false, globalstatus = false,
refresh = { refresh = {
statusline = 1000, statusline = 100,
-- tabline = 1000, tabline = 100,
winbar = 1000, winbar = 100,
}, },
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diff", getCitc, isCiderLspAttached }, lualine_b = { "branch", "diff" },
lualine_c = { lualine_c = {
getLightbulb, require("nvim-lightbulb").get_status_text,
{ {
"filename", "filename",
path = 4, -- 0 = just filename, 1 = relative path, 2 = absolute path path = 4, -- 0 = just filename, 1 = relative path, 2 = absolute path

View File

@ -40,6 +40,7 @@ end
local keys = { local keys = {
-- { "<leader>e", ":lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" }, -- { "<leader>e", ":lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>ts", require('telescope.builtin').live_grep }, { "<leader>ts", require('telescope.builtin').live_grep },
{ "<leader>tb", ":Telescope buffers<CR>" },
{ "<leader>TS", function() require('telescope.builtin').live_grep { default_text = vim.fn.expand("<cword>") } end, }, { "<leader>TS", function() require('telescope.builtin').live_grep { default_text = vim.fn.expand("<cword>") } end, },
{ {
"<leader>t.", "<leader>t.",