add golang configuration
This commit is contained in:
parent
2d4fe69a06
commit
c3994e069c
12
init.lua
12
init.lua
|
@ -587,7 +587,17 @@ require('mason-lspconfig').setup()
|
||||||
-- define the property 'filetypes' to the map in question.
|
-- define the property 'filetypes' to the map in question.
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
-- clangd = {},
|
||||||
-- gopls = {},
|
gopls = {
|
||||||
|
gopls = {
|
||||||
|
completeUnimported = true,
|
||||||
|
usePlaceholders = true,
|
||||||
|
analyses = {
|
||||||
|
unusedparams = true,
|
||||||
|
showdown = true,
|
||||||
|
unusedvariable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
-- pyright = {},
|
-- pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- tsserver = {},
|
-- tsserver = {},
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
### NULL-LS
|
||||||
|
|
||||||
|
`goland`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
go install github.com/incu6us/goimports-reviser/v3@latest
|
||||||
|
go install mvdan.cc/gofumpt@latest
|
||||||
|
go install github.com/segmentio/golines@latest
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
return {
|
||||||
|
'olexsmir/gopher.nvim',
|
||||||
|
ft = 'go',
|
||||||
|
config = function(_, opts)
|
||||||
|
require('gopher').setup(opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>gsj", "<CMD>GoTagAdd json<CR>", { desc = '[G]o add [S]truct [J]SON' })
|
||||||
|
end,
|
||||||
|
build = function()
|
||||||
|
vim.cmd [[silent! GoInstallDeps]]
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
return {
|
||||||
|
'jose-elias-alvarez/null-ls.nvim',
|
||||||
|
ft = 'go',
|
||||||
|
config = function()
|
||||||
|
local null_ls = require('null-ls')
|
||||||
|
local augroup = vim.api.nvim_create_augroup('LspFormatting', {})
|
||||||
|
|
||||||
|
null_ls.setup {
|
||||||
|
sources = {
|
||||||
|
null_ls.builtins.formatting.goimports_reviser,
|
||||||
|
null_ls.builtins.formatting.gofumpt,
|
||||||
|
null_ls.builtins.formatting.golines,
|
||||||
|
},
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
if client.supports_method('textDocument/formatting') then
|
||||||
|
vim.api.nvim_clear_autocmds({
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({ bufnr = bufnr })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
Loading…
Reference in New Issue