Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share server for one neovim session #170

Open
ray-x opened this issue Sep 23, 2021 · 0 comments
Open

Share server for one neovim session #170

ray-x opened this issue Sep 23, 2021 · 0 comments

Comments

@ray-x
Copy link
Contributor

ray-x commented Sep 23, 2021

I found in some cases, efm will startup multiple server instances:

LspInfo:

 
 Language client log: /Users/ray/.cache/nvim/lsp.log
 Detected filetype:   lua
 
 2 client(s) attached to this buffer: 
 
 Client: sumneko_lua (id: 1, pid: 77948, bufnr: [1, 1, 2])
 ...
 
 Client: efm (id: 3, pid: 77957, bufnr: [2])
 	filetypes:       javascript, javascriptreact, typescript, typescriptreact, html, css, go, lua, sql, json, markdown, scss, yaml, javascript.jsx, less, graphql, vue, svelte
 	autostart:       true
 	root directory:  /Users/ray/github/navigator.lua/lua/navigator
 	cmd:             efm-langserver -loglevel 1 -logfile /Users/ray/tmp/efm.log
 
 1 active client(s) not attached to this buffer: 
 
 Client: efm (id: 2, pid: 77949, bufnr: [1, 1])
 	filetypes:       javascript, javascriptreact, typescript, typescriptreact, html, css, go, lua, sql, json, markdown, scss, yaml, javascript.jsx, less, graphql, vue, svelte
 	autostart:       true
 	root directory:  /Users/ray/github/navigator.lua/lua
 	cmd:             efm-langserver -loglevel 1 -logfile /Users/ray/tmp/efm.log

And efm setup:

  local efm_cfg = {
    flags = {debounce_text_changes = 2000},
    cmd = {'efm-langserver', '-loglevel', '1', '-logfile', vim.fn.expand("$HOME") .. '/tmp/efm.log'}, -- 1~10
    init_options = {documentFormatting = true, codeAction = false, document_formatting = true},
    root_dir = require'lspconfig'.util.root_pattern({'.git/', 'package.json', '.'}),
    on_attach = function(client)
      client.resolved_capabilities.document_formatting = true
      client.resolved_capabilities.goto_definition = false
      vim.cmd([[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting()]])
    end,
    filetypes = {
       'go', 'lua','sql',
    },

    settings = {
      rootMarkers = {".git/", 'package.json', 'Makefile', 'go.mod'},
      lintDebounce = "1s",
      formatDebounce = "1000ms",
      languages = {
        go = {
          {
            formatCommand = "golines --max-len=120  --base-formatter=gofumpt",
            formatStdin = true,
            lintCommand = "golangci-lint run",
            LintSeverity = 3
          }
        },
        lua = {
          {
            formatCommand = "lua-format --indent-width 2 --tab-width 2 --no-use-tab --column-limit 120 --column-table-limit 100 --no-keep-simple-function-one-line --no-chop-down-table --chop-down-kv-table --no-keep-simple-control-block-one-line --no-keep-simple-function-one-line --no-break-after-functioncall-lp --no-break-after-operator",
            formatStdin = true
          }
        },
      }
    }
  }

require'lspconfig'.efm.setup(efm_cfg)

step to reproduce:

Suppose I am in root dir of repo navigator.lua

neovim -u vimrc   lua/navigator.lua lua/navigator/cclshierarchy.lua

And switch between buffer with :bn, :bp
Run LspInfo and saw efm started two instances.

Expected behavior:
As the rootMarker is .git and both file are lua. It should use one instance of efm-language-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant