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