mattn / efm-langserver

General purpose Language Server
MIT License
1.34k stars 61 forks source link

`root-markers` configuration not working with `nvim-lspconfig` #190

Closed itaranto closed 1 year ago

itaranto commented 2 years ago

Hello,

I have some questions regarding how efm-langserver works with nvim-lspconfig. I'm not a LSP expert BTW.

It seems that my custom root-markers do not override the root_dir config from nvim-lspconfig. Is this expected? Is there anything I'm not understanding here?

This is my efm-langserver config:

version: 2
root-markers:
  - .git/
lint-debounce: 1s

tools:
  json-jq: &json-jq
    lint-command: 'jq'
    lint-stdin: true
    lint-offset: 1
    lint-formats:
      - '%m at line %l, column %c'

  python-flake8: &python-flake8
    lint-command: 'flake8 --stdin-display-name ${INPUT} -'
    lint-stdin: true
    lint-formats:
      - '%f:%l:%c: %m'
    root-markers:
      - .flake8
      - pyproject.toml
      - setup.cfg
      - setup.py

  python-isort: &python-isort
    format-command: 'isort --quiet -'
    format-stdin: true
    root-markers:
      - .isort.cfg
      - pyproject.toml
      - setup.cfg
      - setup.py

  python-mypy: &python-mypy
    lint-command: 'mypy --python-executable $VIRTUAL_ENV/bin/python --show-column-numbers'
    lint-formats:
      - '%f:%l:%c: %trror: %m'
      - '%f:%l:%c: %tarning: %m'
      - '%f:%l:%c: %tote: %m'
    root-markers:
      - mypy.ini
      - pyproject.toml
      - setup.cfg
      - setup.py

  python-yapf: &python-yapf
    format-command: 'yapf --quiet'
    format-stdin: true
    root-markers:
      - .style.yapf
      - .yapfignore
      - pyproject.toml
      - setup.cfg
      - setup.py

  sh-shellcheck: &sh-shellcheck
    lint-command: 'shellcheck -f gcc -x'
    lint-source: 'shellcheck'
    lint-formats:
      - '%f:%l:%c: %trror: %m'
      - '%f:%l:%c: %tarning: %m'
      - '%f:%l:%c: %tote: %m'

  yaml-yamllint: &yaml-yamllint
    lint-command: 'yamllint -f parsable -'
    lint-stdin: true

languages:
  bash:
    - <<: *sh-shellcheck

  json:
    - <<: *json-jq

  python:
    - <<: *python-flake8
    - <<: *python-isort
    - <<: *python-mypy
    - <<: *python-yapf

  sh:
    - <<: *sh-shellcheck

  yaml:
    - <<: *yaml-yamllint

With the previous config, if I open a python directory that doesn't contain a .git directory but a setup.py file then efm-langserver is not launched by Neovim.

Adding the complete list of root markers into nvim-lspconfig's root_dir fixes this, but then, what's the point of root-markers?

I know this question is Neovim-specific, but I thought efm-langserver reported the root markers to Neovim via the LSP protocol.

Nasafato commented 2 years ago

I also encounter this issue. Will try to look into it this week if I have the time.

mattn commented 2 years ago

Sorry, I don't use neovim. Anyone please get us advices.

danielnehrig commented 2 years ago

root_dir is ~= root_markers

root_markers are efm specific and a condition to run a command when its fullfilled the root_dir is lspconfig specific used internally for the lsp setup means: root_dir = setup lsp if those markers are detected root-markers = run these commands if markers are detected

they are not related

itaranto commented 1 year ago

root_dir is ~= root_markers

root_markers are efm specific and a condition to run a command when its fullfilled the root_dir is lspconfig specific used internally for the lsp setup means: root_dir = setup lsp if those markers are detected root-markers = run these commands if markers are detected

they are not related

Now I understand the difference between lspconfig's root_dir and efm's root-markers, thank you.

Closing the issue.