nametake / golangci-lint-langserver

golangci-lint language server
MIT License
221 stars 20 forks source link

connections opened #29

Open RazaGR opened 1 year ago

RazaGR commented 1 year ago

I am seeing this error

.../vim/lsp/rpc.lua:733 "rpc"   "golangci-lint-langserver"  "stderr"    "golangci-lint-langserver: connections opened\n"

my config

return {

  {
    "nvim-treesitter/nvim-treesitter",
    opts = function(_, opts)
      if type(opts.ensure_installed) == "table" then
        vim.list_extend(opts.ensure_installed, { "go", "gomod", "gosum", "gowork" })
      end
    end,
  },
  -- correctly setup mason lsp / dap extensions
  {
    "williamboman/mason.nvim",
    opts = function(_, opts)
      if type(opts.ensure_installed) == "table" then
        vim.list_extend(opts.ensure_installed, { "gopls" })
      end
    end,
  },
  {
    "ray-x/go.nvim",
    dependencies = { -- optional packages
      "ray-x/guihua.lua",
      "neovim/nvim-lspconfig",
      "nvim-treesitter/nvim-treesitter",
    },
    config = function()
      require("go").setup()
    end,
    event = { "cmdlineenter" },
    ft = { "go", "gomod" },
    build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries
  },
  {
    "neovim/nvim-lspconfig",
    opts = {
      -- make sure mason installs the servers
      servers = {
        golangci_lint_ls = {},
        gopls = {
          gofumpt = true,
          codelenses = {
            gc_details = false,
            generate = true,
            regenerate_cgo = true,
            run_govulncheck = true,
            test = true,
            tidy = true,
            upgrade_dependency = true,
            vendor = true,
          },
          hints = {
            assignVariableTypes = true,
            compositeLiteralFields = true,
            compositeLiteralTypes = true,
            constantValues = true,
            functionTypeParameters = true,
            parameterNames = true,
            rangeVariableTypes = true,
          },
          usePlaceholders = true,
          completeUnimported = true,
          staticcheck = true,
          directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
        },
      },
    },
  },
,}

go env

GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/raza/go/bin"
GOCACHE="/Users/raza/Library/Caches/go-build"
GOENV="/Users/raza/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/raza/go/pkg/mod"
GONOPROXY="gitlab.pensionera.io"
GONOSUMDB="gitlab.pensionera.io"
GOOS="darwin"
GOPATH="/Users/raza/go"
GOPRIVATE="gitlab.pensionera.io"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tx/ny8xz3vs2wn39kchcbhmdl840000gn/T/go-build3306080220=/tmp/go-build -gno-record-gcc-switches -fno-common"

neovim

NVIM v0.8.4-dev-2+gb1ae775de

gopls

golang.org/x/tools/gopls v0.11.0
    golang.org/x/tools/gopls@v0.11.0 h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY=
rtmor commented 1 year ago

I'm also using LazyNvim. I was able to initialize this plugin by using the following configuration:

-- nvim-lspconfig.lua

return {
  "neovim/nvim-lspconfig",
  opts = {
    servers = {
      golangci_lint_ls = {
        cmd = { "golangci-lint-langserver" },
        root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"),
        init_options = {
          command = { "golangci-lint", "run", "--enable-all", "--disable", "depguard", "--out-format", "json" },
        },
      },
    },
  },
}

There's probably a nicer way to handle this, but it seems to be working well for me.

Hope that helps.