Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The plugin covers most features required for a gopher.

**Formatting & Linting**

- Format via LSP (gopls) or CLI (`gofumpt`, `goimports`, `golines`)
- Format via LSP (gopls) or CLI (`gofumpt`, `goimports`)
- Lint with golangci-lint (v2) — LSP diagnostics or async background checks

**Debugging**
Expand Down
12 changes: 3 additions & 9 deletions doc/advanced-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ require('go').setup({
-- settings with {}; string will be set to ''. user need to setup ALL the settings
-- It is import to set ALL values in your own config if set value to true otherwise the plugin may not work
go='go', -- go command, can be go[default] or e.g. go1.18beta1
goimports ='gopls', -- goimports command, can be gopls[default] or either goimports or golines if need to split long lines
gofmt = 'gopls', -- gofmt through gopls: alternative is gofumpt, goimports, golines, gofmt, etc
goimports ='gopls', -- goimports command, can be gopls[default]
gofmt = 'gopls', -- gofmt through gopls: alternative is gofumpt, goimports, gofmt, etc
fillstruct = 'gopls', -- set to fillstruct if gopls fails to fill struct
max_line_len = 0, -- max line length in golines format, Target maximum line length for golines
max_line_len = 0, -- max line length, Target maximum line length
tag_transform = false, -- can be transform option("snakecase", "camelcase", etc) check gomodifytags for details and more options
tag_options = 'json=omitempty', -- sets options sent to gomodifytags, i.e., json=omitempty
gotests_template = "", -- sets gotests -template parameter (check gotests for details)
Expand Down Expand Up @@ -533,12 +533,6 @@ Gotest allow you run `go test <package>` when you save your go file and add diag
local null_ls = require("null-ls")
local sources = {
null_ls.builtins.diagnostics.revive,
null_ls.builtins.formatting.golines.with({
extra_args = {
"--max-len=180",
"--base-formatter=gofumpt",
},
})
}
-- for go.nvim
local gotest = require("go.null_ls").gotest()
Expand Down
7 changes: 3 additions & 4 deletions doc/go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ BINARIES *go-nvim-binaries*
gotest `go test`
golint `golangci-lint`
gotags
golines
goimports


Expand Down Expand Up @@ -248,7 +247,7 @@ COVERAGE ~
FORMAT & IMPORTS ~

:GoFmt {formatter} *:GoFmt*
Format code. Optional arg: gofmt, goimports, gofumpt, golines.
Format code. Optional arg: gofmt, goimports, gofumpt.
Default configured via |gofmt| option.

:GoImports {package_name} *:GoImports*
Expand Down Expand Up @@ -678,8 +677,8 @@ You can setup go.nvim with following options:
go = "go", -- go binary, e.g. "go1.21"
goimports = "gopls", -- "gopls" uses gopls format, also "goimports"
fillstruct = "gopls", -- "gopls" or "fillstruct"
gofmt = "gopls", -- "gopls", "gofumpt", "gofmt", "golines"
max_line_len = 0, -- max line length for golines (0 = disabled)
gofmt = "gopls", -- "gopls", "gofumpt", "gofmt"
max_line_len = 0, -- max line length (0 = disabled)
tag_transform = false, -- gomodifytags transform, e.g. "snakecase"
tag_options = "json=omitempty", -- gomodifytags default tag options
gotests_template = "", -- gotests -template parameter
Expand Down
3 changes: 1 addition & 2 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ false.
The following go binaries are used in `go.nvim` (depends on your setup):

- gofumpt
- golines
- goimports
- gorename
- gomodifytags
Expand All @@ -149,7 +148,7 @@ The following go binaries are used in `go.nvim` (depends on your setup):
- govulncheck
- goenum

If you run `GoFmt` and the configured binary (e.g. golines) was not installed, the plugin will install it for you. But
If you run `GoFmt` and the configured binary was not installed, the plugin will install it for you. But
the first run of `GoFmt` may fail. Recommended to run `GoInstallBinaries` to install all binaries before using the
plugin.

Expand Down
6 changes: 1 addition & 5 deletions lua/go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _GO_NVIM_CFG = {
null_ls_document_formatting_disable = false, -- true: disable null-ls formatting
-- if enable gopls to format the code and you also installed and enabled null-ls, you may
-- want to disable null-ls by setting this to true
-- it can be a nulls source name e.g. `golines` or a nulls query table
-- it can be a nulls source name e.g. a nulls query table
lsp_keymaps = true, -- true: use default keymaps defined in go/lsp.lua
lsp_codelens = true,
golangci_lint = {
Expand Down Expand Up @@ -262,10 +262,6 @@ function go.setup(cfg)
vim.notify('go.nvim go binary is not setup', vim.log.levels.ERROR)
end

if _GO_NVIM_CFG.max_line_len > 0 and _GO_NVIM_CFG.gofmt ~= 'golines' then
vim.notify('go.nvim max_line_len only effective when gofmt is golines', vim.log.levels.WARN)
end

require('go.commands').add_cmds()
vim.defer_fn(function()
require('go.project').load_project()
Expand Down
2 changes: 1 addition & 1 deletion lua/go/ai/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ BUILD & RUN:
- GoStop [job] — Stop a running async job
FORMAT & IMPORTS:
- GoFmt [formatter] — Format file. Args: gofmt, goimports, gofumpt, golines
- GoFmt [formatter] — Format file. Args: gofmt, goimports, gofumpt
- GoImports [pkg] — Add/remove imports. Args: optional package to import
CODE GENERATION:
Expand Down
10 changes: 1 addition & 9 deletions lua/go/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ end
M.gofmt = function(...)
local gofmt = _GO_NVIM_CFG.gofmt or 'gopls'
local gofmt_args = _GO_NVIM_CFG.gofmt_args
or gofmt == 'golines' and {
'--max-len=' .. tostring(max_len),
'--base-formatter=gofumpt',
}
or {}
local long_opts = {
all = 'a',
Expand Down Expand Up @@ -165,15 +161,11 @@ M.goimports = function(...)
end
local buf = vim.api.nvim_get_current_buf()
-- specified the pkg name
if #args > 0 then -- dont use golines
if #args > 0 then
return run(args, buf, 'goimports')
end

-- golines base formatter is goimports
local a = {}
if goimports == 'golines' then
a = vim.deepcopy(goimport_args)
end
run(a, buf, goimports)
end

Expand Down
1 change: 0 additions & 1 deletion lua/go/install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local log = utils.log

local url = {
gofumpt = 'mvdan.cc/gofumpt',
golines = 'github.com/segmentio/golines',
['golangci-lint'] = 'github.com/golangci/golangci-lint/v2/cmd/golangci-lint',
goimports = 'golang.org/x/tools/cmd/goimports',
gomodifytags = 'github.com/fatih/gomodifytags',
Expand Down
Loading