feat: add go lsp and formatting
This commit is contained in:
@@ -4,6 +4,7 @@ local options = {
|
||||
python = { "black" },
|
||||
css = { "prettier" },
|
||||
html = { "prettier" },
|
||||
go = { "goimports", "gofmt" },
|
||||
},
|
||||
|
||||
-- format_on_save = {
|
||||
|
||||
@@ -5,6 +5,7 @@ local capabilities = require("nvchad.configs.lspconfig").capabilities
|
||||
|
||||
local lspconfig = require "lspconfig"
|
||||
local servers = { "html", "cssls", "clangd" }
|
||||
local util = require "lspconfig/util"
|
||||
|
||||
-- lsps with default config
|
||||
for _, lsp in ipairs(servers) do
|
||||
@@ -35,6 +36,23 @@ lspconfig.basedpyright.setup{
|
||||
}
|
||||
}
|
||||
|
||||
lspconfig.gopls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = {"gopls"},
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
|
||||
settings = {
|
||||
gopls = {
|
||||
completeUnimported = true,
|
||||
usePlaceholders = true,
|
||||
analyses = {
|
||||
unusedParameters = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---- ruff_lsp and pyright compatibility
|
||||
local on_attach = function(client, bufnr)
|
||||
if client.name == 'ruff_lsp' then
|
||||
|
||||
@@ -24,14 +24,11 @@ return {
|
||||
"html-lsp",
|
||||
"css-lsp",
|
||||
"prettier",
|
||||
"basedpyright",
|
||||
"mypy",
|
||||
"black",
|
||||
"ruff-lsp",
|
||||
"basedpyright", "mypy", "black", "ruff-lsp",
|
||||
"typescript-language-server",
|
||||
"clangd",
|
||||
"goimports", "gofumpt", "gomodifytags", "impl", "delve",
|
||||
},
|
||||
automatic_installation = true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -45,7 +42,11 @@ return {
|
||||
"html",
|
||||
"css",
|
||||
"python",
|
||||
"typescript"
|
||||
"typescript",
|
||||
"go",
|
||||
"gomod",
|
||||
"gowork",
|
||||
"gosum",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user