diff --git a/README.md b/README.md index 06408f297..464f822c0 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/doc/advanced-setup.md b/doc/advanced-setup.md index 3efb12f2e..8d11ab2b2 100644 --- a/doc/advanced-setup.md +++ b/doc/advanced-setup.md @@ -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) @@ -533,12 +533,6 @@ Gotest allow you run `go test ` 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() diff --git a/doc/go.txt b/doc/go.txt index 371a6e612..6254d0acf 100644 --- a/doc/go.txt +++ b/doc/go.txt @@ -102,7 +102,6 @@ BINARIES *go-nvim-binaries* gotest `go test` golint `golangci-lint` gotags - golines goimports @@ -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* @@ -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 diff --git a/doc/usage.md b/doc/usage.md index 5cc4135b2..267e1ade5 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -134,7 +134,6 @@ false. The following go binaries are used in `go.nvim` (depends on your setup): - gofumpt -- golines - goimports - gorename - gomodifytags @@ -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. diff --git a/lua/go.lua b/lua/go.lua index 9d81a9f9c..82f32b8c0 100644 --- a/lua/go.lua +++ b/lua/go.lua @@ -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 = { @@ -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() diff --git a/lua/go/ai/init.lua b/lua/go/ai/init.lua index cd7e6dea2..229ca10e9 100644 --- a/lua/go/ai/init.lua +++ b/lua/go/ai/init.lua @@ -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: diff --git a/lua/go/format.lua b/lua/go/format.lua index 76b7affc1..9ad1e486f 100644 --- a/lua/go/format.lua +++ b/lua/go/format.lua @@ -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', @@ -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 diff --git a/lua/go/install.lua b/lua/go/install.lua index 1997a4f70..581dba605 100644 --- a/lua/go/install.lua +++ b/lua/go/install.lua @@ -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',