ray-x / navigator.lua

Code analysis & navigation plugin for Neovim. Navigate codes like a breeze🎐 Exploring LSP and 🌲Treesitter symbols a piece of 🍰 Take control like a boss 🦍
MIT License
1.27k stars 54 forks source link

Help with migration from lsp-installer to mason.nvim #226

Open kozikowskik opened 1 year ago

kozikowskik commented 1 year ago

Hi, Today I tried to switch from lsp-installer to mason.nvim and mason-lspconfig.nvim but I'm facing problems or I'm doing something wrong in the configuration and I don't see what. For testing I prepared a fresh neovim installation with packer and minimum configuration required to run ray-x/navigator.lua, mason.nvim and mason-lspconfig.nvim.With :LspInstall I installed pyright. As result, I want to have running pyright as my lsp-serve for python files but when I run :LspInfo on some dummy python script I'm getting information that any of lsp clients is attached to buffer.

          Use [q] or [Esc] to quit the window                                                                                                                                     
~                                                                                                                                                                                             
~                     Language client log: /root/.cache/nvim/lsp.log                                                                                                                          
~                     Detected filetype:   python                                                                                                                                             
~                                                                                                                                                                                             
~                     0 client(s) attached to this buffer:                                                                                                                                    
~                                                                                                                                                                                             
~                     Configured servers list:                                                                                                                                                
~                                                 

Additional informations

Neovim version:

root@749fbc5e5807:/# nvim --version
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by team+vim@tracker.debian.org

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
root@749fbc5e5807:/# 

My nvim configuration file looks like that:

return require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'

  use("williamboman/mason.nvim")
  use({
          "williamboman/mason-lspconfig.nvim",
          config = function()
                  require("mason").setup()
                  require("mason-lspconfig").setup({})
          end,
  })
  use {"neovim/nvim-lspconfig"}
  use({
          "ray-x/navigator.lua",
          requires = {
                  { "ray-x/guihua.lua", run = "cd lua/fzy && make" },
                  { "neovim/nvim-lspconfig" },
                  { "nvim-treesitter/nvim-treesitter" },
          },
          config = function()
                  require("navigator").setup({
                          debug = true,
                          mason = true,
                  })
          end,
  })
end)

When I run :LspInstall inside the buffer I'm getting list of available servers with information that pyright is already installed:

Please select which server you want to install for filetype "python":
1: jedi_language_server
2: pylsp
3: pyright (installed)
4: sourcery
Type number and <Enter> or click with the mouse (q or empty cancels):

Navigator.lua debug log

root@749fbc5e5807:/# cat  ~/.cache/nvim/gh.log 
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:105: lsp_installer: { "pyright" }
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:551: nil filetype, callback
[INFO][Sat Sep  3 12:58:42 2022] [3]...packer/start/navigator.lua/lua/navigator/diagnostics.lua:542: diag config {
  severity_sort = {
    reverse = true
  },
  underline = true,
  update_in_insert = false,
  virtual_text = {
    prefix = "__",
    source = true,
    spacing = 3
  }
}
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:651: {}
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:666: file:///test.py
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:605: running lsp setup python 1
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:608: loading for ft  python file:///test.py
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:324: pylsp
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:327: pylsp {}
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:403: loading pylsp name pylsp has lspinst false
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:439: mason server not installed pylsp
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:651: { 1 }
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:666: file:///test.py
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:605: running lsp setup python 1
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:608: loading for ft  python file:///test.py
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:324: pylsp
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:327: pylsp {}
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:403: loading pylsp name pylsp has lspinst false
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:439: mason server not installed pylsp
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:563: defer_fn py 
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:605: running lsp setup python 1
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:608: loading for ft  python file:///test.py
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:324: pylsp
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:327: pylsp {}
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:403: loading pylsp name pylsp has lspinst false
[INFO][Sat Sep  3 12:58:42 2022] [3].../start/navigator.lua/lua/navigator/lspclient/clients.lua:439: mason server not installed pylsp
ray-x commented 1 year ago

I create a feature request in mason: https://github.com/williamboman/mason-lspconfig.nvim/issues/44

the reason is pylsp was install in virtual env path. It is not a binary lspconfig usually deal with. You can setup pylsp by set navigator.setup{lsp={ pylsp ={ cmd={'mason_install_path'} } ATM