googlepaths

This commit is contained in:
Christian Nieves
2025-02-05 18:01:16 +00:00
parent 8b8046878f
commit 053eeb07fd

View File

@ -1,7 +1,7 @@
local use_google = require("utils").use_google local use_google = require("utils").use_google
if not use_google() then if not use_google() then
return {} return {}
end end
vim.opt.rtp:append("/google/src/head/depot/google3/experimental/users/fentanes/nvgoog/") vim.opt.rtp:append("/google/src/head/depot/google3/experimental/users/fentanes/nvgoog/")
@ -11,73 +11,69 @@ local glugOpts = require("glug").glugOpts
local superlazy = require("nvgoog.util.superlazy") local superlazy = require("nvgoog.util.superlazy")
return { return {
-- { url = "sso://user/fentanes/nvgoog" }, { import = "nvgoog.google.format" },
-- Prevent long sessions from losing cwd -- maktaba is required by all google plugins
-- Load google paths like //google/* with `gf` glug("maktaba", {
-- { import = "nvgoog.google.misc" }, lazy = true,
{ import = "nvgoog.google.format" }, dependencies = {},
-- maktaba is required by all google plugins config = function() -- init?
glug("maktaba", { vim.cmd("source /usr/share/vim/google/glug/bootstrap.vim")
lazy = true, end,
dependencies = {}, }),
config = function() -- init? glug("googler", {
vim.cmd("source /usr/share/vim/google/glug/bootstrap.vim") event = "VeryLazy",
end, }),
}), glug("glaive"),
glug("googler", { glug("alert"),
event = "VeryLazy", glug("googlespell"),
}), -- Add support for google filetypes
glug("glaive"), glug("google-filetypes", { event = { "BufReadPre", "BufNewFile" }, dependencies = {} }),
glug("alert"),
glug("googlespell"),
-- Add support for google filetypes
glug("google-filetypes", { event = { "BufReadPre", "BufNewFile" }, dependencies = {} }),
glug("add_usings"), glug("add_usings"),
-- Autogens boilerplate when creating new files -- Autogens boilerplate when creating new files
glug("autogen", { glug("autogen", {
event = "BufNewFile", event = "BufNewFile",
}), }),
-- Adds G4 support to the vcscommand plugin -- Adds G4 support to the vcscommand plugin
glug("googlepaths"), glug("googlepaths"),
-- Set up syntax, indent, and core settings for various filetypes -- Set up syntax, indent, and core settings for various filetypes
superlazy(glug("ft-cpp", { event = "BufRead,BufNewFile *.[ch],*.cc,*.cpp" })), superlazy(glug("ft-cpp", { event = "BufRead,BufNewFile *.[ch],*.cc,*.cpp" })),
-- superlazy(glug("ft-go", { event = "BufRead,BufNewFile *.go" })), -- superlazy(glug("ft-go", { event = "BufRead,BufNewFile *.go" })),
superlazy(glug("ft-java", { event = "BufRead,BufNewFile *.java" })), superlazy(glug("ft-java", { event = "BufRead,BufNewFile *.java" })),
superlazy(glug("ft-javascript", { event = "BufRead,BufNewFile *.js,*.jsx" })), superlazy(glug("ft-javascript", { event = "BufRead,BufNewFile *.js,*.jsx" })),
superlazy(glug("ft-kotlin", { event = "BufRead,BufNewFile *.kt,*.kts" })), superlazy(glug("ft-kotlin", { event = "BufRead,BufNewFile *.kt,*.kts" })),
superlazy(glug("ft-python", { event = "BufRead,BufNewFile *.py" })), superlazy(glug("ft-python", { event = "BufRead,BufNewFile *.py" })),
-- Configures nvim to respect Google's coding style -- Configures nvim to respect Google's coding style
superlazy(glug("googlestyle", { event = { "BufRead", "BufNewFile" } })), superlazy(glug("googlestyle", { event = { "BufRead", "BufNewFile" } })),
glug("ft-soy"), glug("ft-soy"),
glug("ft-gss"), glug("ft-gss"),
glug("ft-proto"), glug("ft-proto"),
glug("g4"), glug("g4"),
glug("outline-window"), glug("outline-window"),
glug("fzf-query"), glug("fzf-query"),
-- Open current file in chrome -- Open current file in chrome
glug("corpweb", { glug("corpweb", {
dependencies = { dependencies = {
glug("launchbrowser"), glug("launchbrowser"),
}, },
cmd = { cmd = {
-- Launches {query} under codesearch in a web browser -- Launches {query} under codesearch in a web browser
"CorpWebCs", "CorpWebCs",
-- Launches the current file under codesearch in a web browser -- Launches the current file under codesearch in a web browser
"CorpWebCsFile", "CorpWebCsFile",
-- Launches the current file doc view (i.e., Cantata, G3Docs, or godoc) -- Launches the current file doc view (i.e., Cantata, G3Docs, or godoc)
"CorpWebDocFindFile", "CorpWebDocFindFile",
-- Launches the current CL in Critique -- Launches the current CL in Critique
"CorpWebCritiqueCl", "CorpWebCritiqueCl",
-- Launches the current CL in Cider -- Launches the current CL in Cider
"CorpWebCider", "CorpWebCider",
-- Launches {query} under cs.chromium.org in a web browser -- Launches {query} under cs.chromium.org in a web browser
"CorpWebChromeCs", "CorpWebChromeCs",
}, },
}), }),
glug("relatedfiles", { glug("relatedfiles", {
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ "<leader>rb", ":exec relatedfiles#selector#JumpToBuild()<CR>" }, { "<leader>rb", ":exec relatedfiles#selector#JumpToBuild()<CR>" },
@ -85,234 +81,234 @@ return {
{ "<leader>rh", ":exec relatedfiles#selector#JumpToHeader()<CR>" }, { "<leader>rh", ":exec relatedfiles#selector#JumpToHeader()<CR>" },
{ "<leader>rc", ":exec relatedfiles#selector#JumpToCodeFile()<CR>" }, { "<leader>rc", ":exec relatedfiles#selector#JumpToCodeFile()<CR>" },
}, },
}), }),
{ "junegunn/fzf", dir = "~/.fzf", build = "./install --all" }, { "junegunn/fzf", dir = "~/.fzf", build = "./install --all" },
{ "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } }, { "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } },
-- Format google code -- Format google code
glug("codefmt-google", { glug("codefmt-google", {
dependencies = { dependencies = {
glug("codefmt", { glug("codefmt", {
opts = { opts = {
clang_format_executable = "/usr/bin/clang-format", clang_format_executable = "/usr/bin/clang-format",
clang_format_style = "function('codefmtgoogle#GetClangFormatStyle')", clang_format_style = "function('codefmtgoogle#GetClangFormatStyle')",
gofmt_executable = "/usr/lib/google-golang/bin/gofmt", gofmt_executable = "/usr/lib/google-golang/bin/gofmt",
prettier_executable = "/google/data/ro/teams/prettier/prettier", prettier_executable = "/google/data/ro/teams/prettier/prettier",
ktfmt_executable = { "/google/bin/releases/kotlin-google-eng/ktfmt/ktfmt", "--google-style" }, ktfmt_executable = { "/google/bin/releases/kotlin-google-eng/ktfmt/ktfmt", "--google-style" },
}, },
}), }),
}, },
opts = { opts = {
auto_format = { auto_format = {
["borg"] = "gclfmt", ["borg"] = "gclfmt",
["gcl"] = "gclfmt", ["gcl"] = "gclfmt",
["patchpanel"] = "gclfmt", ["patchpanel"] = "gclfmt",
["bzl"] = "buildifier", ["bzl"] = "buildifier",
["c"] = "clang-format", ["c"] = "clang-format",
["cpp"] = "clang-format", ["cpp"] = "clang-format",
["javascript"] = "clang-format", ["javascript"] = "clang-format",
["typescript"] = "clang-format", ["typescript"] = "clang-format",
["dart"] = "dartfmt", ["dart"] = "dartfmt",
["go"] = "gofmt", ["go"] = "gofmt",
["java"] = "google-java-format", ["java"] = "google-java-format",
["kotlin"] = "ktfmt", ["kotlin"] = "ktfmt",
["jslayout"] = "jslfmt", ["jslayout"] = "jslfmt",
["markdown"] = "mdformat", ["markdown"] = "mdformat",
["ncl"] = "nclfmt", ["ncl"] = "nclfmt",
["python,piccolo"] = "pyformat", ["python,piccolo"] = "pyformat",
["soy"] = "soyfmt", ["soy"] = "soyfmt",
["textpb"] = "text-proto-format", ["textpb"] = "text-proto-format",
["proto"] = "protofmt", ["proto"] = "protofmt",
["sql"] = "format_sql", ["sql"] = "format_sql",
}, },
}, },
cmd = { "FormatLines", "FormatCode", "AutoFormatBuffer" }, cmd = { "FormatLines", "FormatCode", "AutoFormatBuffer" },
event = "VimEnter", event = "VimEnter",
-- Setting up autocmds in init allows deferring loading the plugin until -- Setting up autocmds in init allows deferring loading the plugin until
-- the `BufWritePre` event. One caveat is we must call `codefmt#FormatBuffer()` -- the `BufWritePre` event. One caveat is we must call `codefmt#FormatBuffer()`
-- manually the first time since the plugin relies on the `BufWritePre` command to call it, -- manually the first time since the plugin relies on the `BufWritePre` command to call it,
-- but by the time it's first loaded it has already happened. -- but by the time it's first loaded it has already happened.
-- TODO: check if that is fixed when the following issue is fixed -- TODO: check if that is fixed when the following issue is fixed
-- https://github.com/folke/lazy.nvim/issues/858 -- https://github.com/folke/lazy.nvim/issues/858
-- if so, remove the call to `FormatBuffer` -- if so, remove the call to `FormatBuffer`
init = function(plugin) init = function(plugin)
local group = vim.api.nvim_create_augroup("autoformat_settings", {}) local group = vim.api.nvim_create_augroup("autoformat_settings", {})
local function autocmd(filetypes, formatter) local function autocmd(filetypes, formatter)
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes, pattern = filetypes,
group = group, group = group,
callback = function(event) callback = function(event)
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
buffer = event.buf, buffer = event.buf,
group = group, group = group,
once = true, once = true,
command = "call codefmt#FormatBuffer() | AutoFormatBuffer " .. formatter, command = "call codefmt#FormatBuffer() | AutoFormatBuffer " .. formatter,
}) })
end, end,
}) })
end end
-- Build opts from possible parent specs since lazy.nvim doesn't provide it in `init` -- Build opts from possible parent specs since lazy.nvim doesn't provide it in `init`
local plugin_opts = require("lazy.core.plugin").values(plugin, "opts", false) local plugin_opts = require("lazy.core.plugin").values(plugin, "opts", false)
for filetypes, formatter in pairs(plugin_opts.auto_format or {}) do for filetypes, formatter in pairs(plugin_opts.auto_format or {}) do
autocmd(filetypes, formatter) autocmd(filetypes, formatter)
end end
end, end,
}), }),
-- Run blaze commands -- Run blaze commands
glug("blaze", { glug("blaze", {
dependencies = { dependencies = {
glug("blazedeps"), glug("blazedeps"),
}, },
cmd = { cmd = {
"Blaze", "Blaze",
"BlazeGoToSponge", "BlazeGoToSponge",
"BlazeViewCommandLog", "BlazeViewCommandLog",
"BlazeLoadErrors", "BlazeLoadErrors",
"BlazeDebugCurrentFileTest", "BlazeDebugCurrentFileTest",
"BlazeDebugCurrentTestMethod", "BlazeDebugCurrentTestMethod",
"BlazeDebugAddBreakpoint", "BlazeDebugAddBreakpoint",
"BlazeDebugClearBreakpoint", "BlazeDebugClearBreakpoint",
"BlazeDebugFinish", "BlazeDebugFinish",
"BlazeDepsUpdate", "BlazeDepsUpdate",
}, },
keys = function() keys = function()
local function runCommandWithTarget(cmd) local function runCommandWithTarget(cmd)
return function() return function()
local targets = table.concat(vim.fn["blaze#GetTargets"](), " ") local targets = table.concat(vim.fn["blaze#GetTargets"](), " ")
local command = "VimuxRunCommand('" .. cmd .. " " .. targets .. "')" local command = "VimuxRunCommand('" .. cmd .. " " .. targets .. "')"
print(vim.inspect(command)) print(vim.inspect(command))
vim.cmd(command) vim.cmd(command)
end end
end end
return { return {
{ "<leader>b", desc = "Blaze" }, { "<leader>b", desc = "Blaze" },
{ "<leader>bb", runCommandWithTarget("blaze build"), desc = "Blaze Build" }, { "<leader>bb", runCommandWithTarget("blaze build"), desc = "Blaze Build" },
{ "<leader>br", runCommandWithTarget("blaze run"), desc = "Blaze Run" }, { "<leader>br", runCommandWithTarget("blaze run"), desc = "Blaze Run" },
{ "<leader>bt", runCommandWithTarget("blaze test"), desc = "Blaze Test" }, { "<leader>bt", runCommandWithTarget("blaze test"), desc = "Blaze Test" },
{ "<leader>bc", runCommandWithTarget("build_cleaner"), desc = "Blaze Run" }, { "<leader>bc", runCommandWithTarget("build_cleaner"), desc = "Blaze Run" },
{ {
"<leader>yb", "<leader>yb",
":let t = join(blaze#GetTargets(), ' ') | echo t | let @+ = t | let @\" = t<CR>", ":let t = join(blaze#GetTargets(), ' ') | echo t | let @+ = t | let @\" = t<CR>",
desc = "Yank Blaze Target", desc = "Yank Blaze Target",
}, },
{ {
"<leader>bq", "<leader>bq",
function() function()
local targets = vim.fn["blaze#GetTargets"]() local targets = vim.fn["blaze#GetTargets"]()
for _, t in ipairs(targets) do for _, t in ipairs(targets) do
print(vim.inspect(t)) print(vim.inspect(t))
vim.cmd("VimuxRunCommand('blaze query " .. t:gsub(":.+", "") .. ":\\*" .. "')") vim.cmd("VimuxRunCommand('blaze query " .. t:gsub(":.+", "") .. ":\\*" .. "')")
end end
end, end,
desc = "Blaze query the current package", desc = "Blaze query the current package",
}, },
} }
end, end,
}), }),
-- Imports -- Imports
glug("imp-google", { glug("imp-google", {
dependencies = { dependencies = {
glugOpts("vim-imp", { glugOpts("vim-imp", {
"flwyd/vim-imp", "flwyd/vim-imp",
opts = { opts = {
["Suggest[default]"] = { "buffer", "csearch", "ripgrep", "prompt" }, ["Suggest[default]"] = { "buffer", "csearch", "ripgrep", "prompt" },
["Report[default]"] = "popupnotify", ["Report[default]"] = "popupnotify",
["Location[default]"] = "packageroot", ["Location[default]"] = "packageroot",
-- ["Location[gcl]"] = "parent", -- ["Location[gcl]"] = "parent",
["Pick[default]"] = "fzf", ["Pick[default]"] = "fzf",
}, },
}), }),
}, },
cmd = { "ImpSuggest", "ImpFirst" }, cmd = { "ImpSuggest", "ImpFirst" },
keys = { keys = {
{ "<leader>i", ":ImpSuggest <C-r><C-w><cr>" }, { "<leader>i", ":ImpSuggest <C-r><C-w><cr>" },
}, },
}), }),
{ {
url = "sso://user/fentanes/googlepaths.nvim", url = "sso://user/fentanes/googlepaths.nvim",
event = { "VeryLazy", "BufReadCmd //*" }, event = { "VeryLazy", "BufReadCmd //*", "BufReadCmd google3/*" },
opts = {}, opts = {},
}, },
{ {
name = "ai.nvim", name = "ai.nvim",
url = "sso://googler@user/vvvv/ai.nvim", url = "sso://googler@user/vvvv/ai.nvim",
}, },
{ {
name = "cmp-nvim-ciderlsp", name = "cmp-nvim-ciderlsp",
url = "sso://googler@user/piloto/cmp-nvim-ciderlsp", url = "sso://googler@user/piloto/cmp-nvim-ciderlsp",
event = "VimEnter", event = "VimEnter",
}, },
{ {
name = "ciderlsp-nvim", name = "ciderlsp-nvim",
url = "sso://googler@user/kdark/ciderlsp-nvim", url = "sso://googler@user/kdark/ciderlsp-nvim",
event = "VimEnter", event = "VimEnter",
}, },
-- { -- {
-- name = "nvim_figtree", -- name = "nvim_figtree",
-- url = "sso://googler@user/jackcogdill/nvim-figtree", -- url = "sso://googler@user/jackcogdill/nvim-figtree",
-- }, -- },
{ {
name = "telescope_codesearch", name = "telescope_codesearch",
url = "sso://googler@user/vintharas/telescope-codesearch.nvim", url = "sso://googler@user/vintharas/telescope-codesearch.nvim",
dependencies = { "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-telescope/telescope.nvim" },
config = function() end, config = function() end,
}, },
{ {
name = "telescope_citc", name = "telescope_citc",
url = "sso://googler@user/aktau/telescope-citc.nvim", url = "sso://googler@user/aktau/telescope-citc.nvim",
dependencies = { "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-telescope/telescope.nvim" },
}, },
{ {
name = "telescope_fig", name = "telescope_fig",
url = "sso://googler@user/tylersaunders/telescope-fig.nvim", url = "sso://googler@user/tylersaunders/telescope-fig.nvim",
dependencies = { "nvim-telescope/telescope.nvim" }, dependencies = { "nvim-telescope/telescope.nvim" },
}, },
{ {
name = "critique-nvim", name = "critique-nvim",
dir = "~/critique-nvim/", dir = "~/critique-nvim/",
lazy = false, lazy = false,
dependencies = { dependencies = {
"rktjmp/time-ago.vim", "rktjmp/time-ago.vim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"runiq/neovim-throttle-debounce", "runiq/neovim-throttle-debounce",
}, },
-- here are some mappings you might want: -- here are some mappings you might want:
keys = { keys = {
{ "]c", ":CritiqueGotoNextComment<CR>" }, { "]c", ":CritiqueGotoNextComment<CR>" },
{ "[c", ":CritiqueGotoPrevComment<CR>" }, { "[c", ":CritiqueGotoPrevComment<CR>" },
{ "<Leader>lc", ":CritiqueToggleLineComment<CR>" }, { "<Leader>lc", ":CritiqueToggleLineComment<CR>" },
{ "<Leader>ac", ":CritiqueToggleAllComments<CR>" }, { "<Leader>ac", ":CritiqueToggleAllComments<CR>" },
{ "<Leader>uc", ":CritiqueToggleUnresolvedComments<CR>" }, { "<Leader>uc", ":CritiqueToggleUnresolvedComments<CR>" },
{ "<Leader>fc", ":CritiqueFetchComments<CR>" }, { "<Leader>fc", ":CritiqueFetchComments<CR>" },
{ "<Leader>tc", ":CritiqueCommentsTelescope<CR>" }, { "<Leader>tc", ":CritiqueCommentsTelescope<CR>" },
}, },
config = function() config = function()
-- Here are all the options and their default values: -- Here are all the options and their default values:
require("critique.comments").setup({ require("critique.comments").setup({
-- debug = 1, -- default = 0 -- debug = 1, -- default = 0
-- Fetch the comments after calling `setup`. -- Fetch the comments after calling `setup`.
auto_fetch = true, -- default = true auto_fetch = true, -- default = true
auto_render = true, -- default = true auto_render = true, -- default = true
-- Allow checking for comments on BufEnter events. This is throttled to once every 10 seconds. -- Allow checking for comments on BufEnter events. This is throttled to once every 10 seconds.
frequent_fetch = true, -- default = false frequent_fetch = true, -- default = false
verbose_notifications = true, verbose_notifications = true,
}) })
end, end,
}, },
{ {
url = "sso://googler@user/mccloskeybr/luasnip-google.nvim", url = "sso://googler@user/mccloskeybr/luasnip-google.nvim",
config = function() config = function()
require("luasnip-google").load_snippets() require("luasnip-google").load_snippets()
end, end,
}, },
{ {
name = "hg", name = "hg",
url = "sso://googler@user/smwang/hg.nvim", url = "sso://googler@user/smwang/hg.nvim",
dependencies = { "ipod825/libp.nvim" }, dependencies = { "ipod825/libp.nvim" },
config = function() config = function()
require("hg").setup() require("hg").setup()
end, end,
}, },
} }