diff options
| author | William Boman <william@redwill.se> | 2022-06-09 15:35:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 06:35:32 -0700 |
| commit | 4eac16e87f24ad26738e632446e29766e87141ae (patch) | |
| tree | 234029d64e9c9110fe7ef76b24c2acdcc305d818 /lua | |
| parent | docs: clarify and unverbose (diff) | |
| download | nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar.gz nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar.bz2 nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar.lz nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar.xz nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.tar.zst nvim-lspconfig-4eac16e87f24ad26738e632446e29766e87141ae.zip | |
feat(lspinfo): explain root directory not found #1939
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/ui/lspinfo.lua | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/lua/lspconfig/ui/lspinfo.lua b/lua/lspconfig/ui/lspinfo.lua index 42a7feda..b8e08ad8 100644 --- a/lua/lspconfig/ui/lspinfo.lua +++ b/lua/lspconfig/ui/lspinfo.lua @@ -5,6 +5,12 @@ local util = require 'lspconfig.util' local error_messages = { cmd_not_found = 'Unable to find executable. Please check your path and ensure the server is installed', no_filetype_defined = 'No filetypes defined, Please define filetypes in setup()', + root_dir_not_found = 'Not found.', +} + +local helptags = { + [error_messages.no_filetype_defined] = { 'lspconfig-setup' }, + [error_messages.root_dir_not_found] = { 'lspconfig-root-detection' }, } local function trim_blankspace(cmd) @@ -33,6 +39,7 @@ end local function make_config_info(config) local config_info = {} config_info.name = config.name + config_info.helptags = {} if config.cmd then config_info.cmd = remove_newlines(config.cmd) if vim.fn.executable(config.cmd[1]) == 1 then @@ -46,7 +53,18 @@ local function make_config_info(config) end local buffer_dir = vim.fn.expand '%:p:h' - config_info.root_dir = config.get_root_dir(buffer_dir) or 'NA' + local root_dir = config.get_root_dir(buffer_dir) + if root_dir then + config_info.root_dir = root_dir + else + config_info.root_dir = error_messages.root_dir_not_found + vim.list_extend(config_info.helptags, helptags[error_messages.root_dir_not_found]) + local root_dir_pattern = vim.tbl_get(config, 'document_config', 'docs', 'default_config', 'root_dir') + if root_dir_pattern then + config_info.root_dir = config_info.root_dir .. ' Searched for: ' .. root_dir_pattern .. '.' + end + end + config_info.autostart = (config.autostart and 'true') or 'false' config_info.handlers = table.concat(vim.tbl_keys(config.handlers), ', ') config_info.filetypes = table.concat(config.filetypes or {}, ', ') @@ -64,6 +82,15 @@ local function make_config_info(config) 'custom handlers: ' .. config_info.handlers, } + if vim.tbl_count(config_info.helptags) > 0 then + local help = vim.tbl_map(function(helptag) + return string.format(':h %s', helptag) + end, config_info.helptags) + info_lines = vim.list_extend({ + 'Refer to ' .. table.concat(help, ', ') .. ' for help.', + }, info_lines) + end + vim.list_extend(lines, indent_lines(info_lines, '\t')) return lines @@ -209,8 +236,14 @@ return function() vim.fn.matchadd( 'Error', - error_messages.no_filetype_defined .. '.\\|' .. 'cmd not defined\\|' .. error_messages.cmd_not_found + error_messages.no_filetype_defined + .. '.\\|' + .. 'cmd not defined\\|' + .. error_messages.cmd_not_found + .. '\\|' + .. error_messages.root_dir_not_found ) + vim.cmd 'let m=matchadd("string", "true")' vim.cmd 'let m=matchadd("error", "false")' for _, config in pairs(configs) do |
