fix google formatters

This commit is contained in:
Christian Nieves
2024-01-16 22:43:27 +00:00
parent 80b8c0e214
commit c19d01dc21
2 changed files with 37 additions and 29 deletions

View File

@ -27,7 +27,10 @@ function M.setup(capabilities)
"bzl", "bzl",
"typescript", "typescript",
}, },
root_dir = lspconfig.util.root_pattern("BUILD"), -- root_dir = lspconfig.util.root_pattern("BUILD"),
root_dir = function(fname)
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
end,
settings = {}, settings = {},
}, },
} }
@ -55,7 +58,9 @@ function M.setup(capabilities)
"typescript", "typescript",
"javascript", "javascript",
}, },
root_dir = lspconfig.util.root_pattern("BUILD"), root_dir = function(fname)
return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$")
end,
settings = {}, settings = {},
}, },
} }
@ -83,6 +88,9 @@ function M.setup(capabilities)
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
underline = true, underline = true,
}), }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
focusable = false,
}),
} }
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx) cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)

View File

@ -19,7 +19,7 @@ return {
{ import = "nvgoog.google.misc" }, { import = "nvgoog.google.misc" },
-- maktaba is required by all google plugins -- maktaba is required by all google plugins
glug("maktaba", { glug("maktaba", {
lazy = true, lazy = false,
dependencies = {}, dependencies = {},
config = function() -- init? config = function() -- init?
vim.cmd("source /usr/share/vim/google/glug/bootstrap.vim") vim.cmd("source /usr/share/vim/google/glug/bootstrap.vim")
@ -109,18 +109,20 @@ return {
{ "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } }, { "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } },
-- Format google code -- Format google code
glug("codefmt-google", { glug("codefmt-google", {
lazy = false,
dependencies = { dependencies = {
glug("codefmt", { glug("codefmt", {
-- TODO: remove prettier when http://cl/549024543 is submitted and deployed lazy = false,
-- - remove prettier from the plugin options
-- - set js/ts to use prettier instead of clang-format
-- autocmd FileType javascript,typescript,javascriptreact,typescriptreact,css,scss,html,json AutoFormatBuffer prettier
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 = {
auto_format = { auto_format = {
["borg"] = "gclfmt", ["borg"] = "gclfmt",
["gcl"] = "gclfmt", ["gcl"] = "gclfmt",
@ -144,8 +146,6 @@ return {
["sql"] = "format_sql", ["sql"] = "format_sql",
}, },
}, },
}),
},
cmd = { "FormatLines", "FormatCode", "AutoFormatBuffer" }, cmd = { "FormatLines", "FormatCode", "AutoFormatBuffer" },
event = "BufWritePre", event = "BufWritePre",
-- Setting up autocmds in init allows deferring loading the plugin until -- Setting up autocmds in init allows deferring loading the plugin until