suoto / hdl_checker

Repurposing existing HDL tools to help writing better code
GNU General Public License v3.0
192 stars 22 forks source link

NeoVim Native LSP Configuration errors #93

Closed SethGower closed 3 years ago

SethGower commented 3 years ago

Issue details

The configuration in the readme for the native nvim LSP client doesn't seem to be correct. It should be lspconfig, not nvim_lsp (this requires the lspconfig plugin to be installed, but this is the normal requirement). I also feel like the current directory is a better fall back when a proper root can't be found as opposed to using the home dir. Using home dir leads to exceedingly long load times.

I personally use .hdl_checker.config as root, and if it can't find, it uses current dir. This is simply because at work I deal with projects that are comprised of multiple repos, but need to see files across repos, so I have the .hdl_checker.config in the parent dir to the repos.

I recommend something like this

local nvim_lsp = require'lspconfig'
if not nvim_lsp.hdl_checker then
  require'lspconfig/configs'.hdl_checker = {
    default_config = {
    cmd = {"hdl_checker", "--lsp", };
    filetypes = {"vhdl", "verilog", "systemverilog"};
      root_dir = function(fname)
        return nvim_lsp.util.find_git_ancestor(fname) or util.path.dirname(fname)
      end;
      settings = {};
    };
  }
end

This is my config, from my init.lua in my dotfiles

local lspconfig = require('lspconfig')
local configs = require('lspconfig/configs')
local util = require('lspconfig/util')

if not lspconfig.hdl_checker then
  configs.hdl_checker = {
    default_config = {
      autostart = false, -- disabled auto start since I am giving rust_hdl a shot
      cmd = {"hdl_checker", "--lsp"};
      filetypes = { "vhdl" };
      root_dir = function(fname)
        return util.root_pattern('.hdl_checker.config')(fname) or util.path.dirname(fname)
      end;
      settings = {};
    };
  }
end

(none of the system stuff is really necessary, except for maybe my nvim version)

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



I can eventually make a pull request with this fix. But it might be a bit, since I am busy with work/moving soon.
SethGower commented 3 years ago

additionally, it should specify you need to call some form of


require('lspconfig').hdl_checker.setup()
suoto commented 3 years ago

Good catch :)