diff options
| author | ttys3 <ttys3@outlook.com> | 2021-03-22 15:19:45 +0800 |
|---|---|---|
| committer | 荒野無燈 <ttys3@outlook.com> | 2021-03-24 03:24:31 +0800 |
| commit | 7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7 (patch) | |
| tree | 046a445563a074c62b9a94cf0b58df0e82ab4b55 /lua/lspconfig/vala_ls.lua | |
| parent | [docgen] Update CONFIG.md (diff) | |
| download | nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar.gz nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar.bz2 nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar.lz nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar.xz nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.tar.zst nvim-lspconfig-7b2478b42ce8bb9d63dd2dcd44dc373d19c90cc7.zip | |
refactor(vala): refine vala project root detection
Diffstat (limited to 'lua/lspconfig/vala_ls.lua')
| -rw-r--r-- | lua/lspconfig/vala_ls.lua | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lua/lspconfig/vala_ls.lua b/lua/lspconfig/vala_ls.lua index 3b19786c..f2aba74b 100644 --- a/lua/lspconfig/vala_ls.lua +++ b/lua/lspconfig/vala_ls.lua @@ -1,13 +1,34 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' +local meson_matcher = function (path) + local pattern = "meson.build" + local f = vim.fn.glob(util.path.join(path, pattern)) + if f == '' then + return nil + end + for line in io.lines(f) do + -- skip meson comments + if not line:match('^%s*#.*') then + local str = line:gsub('%s+', '') + if str ~= '' then + if str:match('^project%(') then + return path + else + break + end + end + end + end +end + configs.vala_ls = { default_config = { cmd = {'vala-language-server'}, filetypes = {'vala', 'genie'}, - root_dir = function(fname) - return util.root_pattern("meson.build")(fname) - or util.find_git_ancestor(fname) + root_dir = function (fname) + local root = util.search_ancestors(fname, meson_matcher) + return root or util.find_git_ancestor(fname) end, }, docs = { |
