ci: lint and format with stylua

This commit is contained in:
Michael Lingelbach 2021-07-03 14:45:08 -07:00
parent 30eef6170d
commit ec11b85df7
97 changed files with 1965 additions and 1866 deletions

View File

@ -19,3 +19,14 @@ jobs:
- name: Run luacheck
run: |
sudo make lint
style-lint:
runs-on: [ubuntu-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Lint with stylua
uses: JohnnyMorganz/stylua-action@1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
# CLI arguments
args: --check .

6
.stylua.toml Normal file
View File

@ -0,0 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
no_call_parentheses = true

View File

@ -1,7 +1,7 @@
local configs = require 'lspconfig/configs'
local configs = require "lspconfig/configs"
local M = {
util = require 'lspconfig/util';
util = require "lspconfig/util",
}
local script_path = M.util.script_path()
@ -18,31 +18,31 @@ function M._root._setup()
M._root.commands = {
LspInfo = {
function()
require('lspconfig/lspinfo')()
end;
"-nargs=0";
description = '`:LspInfo` Displays attached, active, and configured language servers';
};
require "lspconfig/lspinfo"()
end,
"-nargs=0",
description = "`:LspInfo` Displays attached, active, and configured language servers",
},
LspStart = {
function(server_name)
if server_name then
require('lspconfig')[server_name].autostart()
require("lspconfig")[server_name].autostart()
else
local buffer_filetype = vim.bo.filetype
for client_name, config in pairs(configs) do
if config.filetypes then
for _, filetype_match in ipairs(config.filetypes) do
if buffer_filetype == filetype_match then
require('lspconfig')[client_name].autostart()
require("lspconfig")[client_name].autostart()
end
end
end
end
end
end;
"-nargs=? -complete=custom,v:lua.lsp_complete_configured_servers";
description = '`:LspStart` Manually launches a language server.';
};
end,
"-nargs=? -complete=custom,v:lua.lsp_complete_configured_servers",
description = "`:LspStart` Manually launches a language server.",
},
LspStop = {
function(client_id)
if not client_id then
@ -53,10 +53,10 @@ function M._root._setup()
client.stop()
end
end
end;
"-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids";
description = '`:LspStop` Manually stops the given language client.';
};
end,
"-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids",
description = "`:LspStop` Manually stops the given language client.",
},
LspRestart = {
function(client_id)
local clients
@ -64,21 +64,21 @@ function M._root._setup()
if client_id == nil then
clients = vim.lsp.buf_get_clients(0)
else
clients = {vim.lsp.get_client_by_id(tonumber(client_id))}
clients = { vim.lsp.get_client_by_id(tonumber(client_id)) }
end
for _, client in ipairs(clients) do
local client_name = client.name
client.stop()
vim.defer_fn(function()
require('lspconfig')[client_name].autostart()
require("lspconfig")[client_name].autostart()
end, 500)
end
end;
"-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids";
description = '`:LspRestart` Manually restart the given language client.';
};
};
end,
"-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids",
description = "`:LspRestart` Manually restart the given language client.",
},
}
M.util.create_module_commands("_root", M._root.commands)
end
@ -88,7 +88,7 @@ function mt:__index(k)
if configs[k] == nil then
-- dofile is used here as a performance hack to increase the speed of calls to setup({})
-- dofile does not cache module lookups, and requires the absolute path to the target file
pcall(dofile, script_path .. 'lspconfig/' .. k .. ".lua")
pcall(dofile, script_path .. "lspconfig/" .. k .. ".lua")
end
return configs[k]
end

View File

@ -34,12 +34,12 @@ function win_float.default_opts(options)
local left = math.floor((vim.o.columns - width) / 2)
local opts = {
relative = 'editor',
row = top,
col = left,
width = width,
height = height,
style = 'minimal'
relative = "editor",
row = top,
col = left,
width = width,
height = height,
style = "minimal",
}
return opts
@ -60,12 +60,12 @@ function win_float.percentage_range_window(col_range, row_range, options)
win_opts.relative = "editor"
local height_percentage, row_start_percentage
if type(row_range) == 'number' then
if type(row_range) == "number" then
assert(row_range <= 1)
assert(row_range > 0)
height_percentage = row_range
row_start_percentage = (1 - height_percentage) / 2
elseif type(row_range) == 'table' then
elseif type(row_range) == "table" then
height_percentage = row_range[2] - row_range[1]
row_start_percentage = row_range[1]
else
@ -73,15 +73,15 @@ function win_float.percentage_range_window(col_range, row_range, options)
end
win_opts.height = math.ceil(vim.o.lines * height_percentage)
win_opts.row = math.ceil(vim.o.lines * row_start_percentage)
win_opts.row = math.ceil(vim.o.lines * row_start_percentage)
local width_percentage, col_start_percentage
if type(col_range) == 'number' then
if type(col_range) == "number" then
assert(col_range <= 1)
assert(col_range > 0)
width_percentage = col_range
col_start_percentage = (1 - width_percentage) / 2
elseif type(col_range) == 'table' then
elseif type(col_range) == "table" then
width_percentage = col_range[2] - col_range[1]
col_start_percentage = col_range[1]
else
@ -91,21 +91,21 @@ function win_float.percentage_range_window(col_range, row_range, options)
win_opts.col = math.floor(vim.o.columns * col_start_percentage)
win_opts.width = math.floor(vim.o.columns * width_percentage)
win_opts.border = {
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"},
{" ", "NormalFloat"}
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
{ " ", "NormalFloat" },
}
local bufnr = options.bufnr or vim.api.nvim_create_buf(false, true)
local win_id = vim.api.nvim_open_win(bufnr, true, win_opts)
vim.api.nvim_win_set_buf(win_id, bufnr)
vim.cmd('setlocal nocursorcolumn')
vim.cmd "setlocal nocursorcolumn"
return {
bufnr = bufnr,

View File

@ -1,21 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local server_name = 'als'
local bin_name = 'ada_language_server'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "als"
local bin_name = "ada_language_server"
if vim.fn.has('win32') == 1 then
bin_name = 'ada_language_server.exe'
if vim.fn.has "win32" == 1 then
bin_name = "ada_language_server.exe"
end
configs[server_name] = {
default_config = {
cmd = {bin_name};
filetypes = {"ada"};
cmd = { bin_name },
filetypes = { "ada" },
-- *.gpr and *.adc would be nice to have here
root_dir = util.root_pattern("Makefile", ".git");
};
root_dir = util.root_pattern("Makefile", ".git"),
},
docs = {
package_json = "https://raw.githubusercontent.com/AdaCore/ada_language_server/master/integration/vscode/ada/package.json";
package_json = "https://raw.githubusercontent.com/AdaCore/ada_language_server/master/integration/vscode/ada/package.json",
description = [[
https://github.com/AdaCore/ada_language_server
@ -33,11 +33,11 @@ require('lspconfig').als.setup{
}
}
```
]];
]],
default_config = {
root_dir = [[util.root_pattern("Makefile", ".git")]];
};
};
};
root_dir = [[util.root_pattern("Makefile", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,7 +1,7 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = 'angularls'
local server_name = "angularls"
-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
-- in order to use your projects configured versions.
@ -9,7 +9,7 @@ local server_name = 'angularls'
local function get_probe_dir(root_dir)
local project_root = util.find_node_modules_ancestor(root_dir)
return project_root and (project_root .. '/node_modules') or ''
return project_root and (project_root .. "/node_modules") or ""
end
local default_probe_dir = get_probe_dir(vim.fn.getcwd())
@ -17,28 +17,32 @@ local default_probe_dir = get_probe_dir(vim.fn.getcwd())
configs[server_name] = {
default_config = {
cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations', default_probe_dir,
'--ngProbeLocations', default_probe_dir
};
filetypes = {'typescript', 'html', 'typescriptreact', 'typescript.tsx'};
"ngserver",
"--stdio",
"--tsProbeLocations",
default_probe_dir,
"--ngProbeLocations",
default_probe_dir,
},
filetypes = { "typescript", "html", "typescriptreact", "typescript.tsx" },
-- Check for angular.json or .git first since that is the root of the project.
-- Don't check for tsconfig.json or package.json since there are multiple of these
-- in an angular monorepo setup.
root_dir = util.root_pattern('angular.json', '.git');
};
root_dir = util.root_pattern("angular.json", ".git"),
},
on_new_config = function(new_config, new_root_dir)
local new_probe_dir = get_probe_dir(new_root_dir)
-- We need to check our probe directories because they may have changed.
new_config.cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations', new_probe_dir,
'--ngProbeLocations', new_probe_dir
"ngserver",
"--stdio",
"--tsProbeLocations",
new_probe_dir,
"--ngProbeLocations",
new_probe_dir,
}
end;
end,
docs = {
description = [[
https://github.com/angular/vscode-ng-language-service
@ -58,9 +62,9 @@ require'lspconfig'.angularls.setup{
end,
}
```
]];
]],
default_config = {
root_dir = [[root_pattern("angular.json", ".git")]];
};
}
root_dir = [[root_pattern("angular.json", ".git")]],
},
},
}

View File

@ -1,31 +1,31 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "bashls"
configs[server_name] = {
default_config = {
cmd = {"bash-language-server", "start"};
cmd = { "bash-language-server", "start" },
cmd_env = {
-- Prevent recursive scanning which will cause issues when opening a file
-- directly in the home directory (e.g. ~/foo.sh).
--
-- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
GLOB_PATTERN = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)"
GLOB_PATTERN = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)",
},
filetypes = {"sh"};
root_dir = util.path.dirname;
};
filetypes = { "sh" },
root_dir = util.path.dirname,
},
docs = {
description = [[
https://github.com/mads-hartmann/bash-language-server
Language server for bash, written using tree sitter in typescript.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,34 +1,33 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "beancount"
local bin_name = "beancount-langserver"
configs[server_name] = {
default_config = {
cmd = {bin_name};
filetypes = {"beancount"};
cmd = { bin_name },
filetypes = { "beancount" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or util.path.dirname(fname)
end;
return util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
init_options = {
-- this is the path to the beancout journal file
journalFile = "",
-- this is the path to the pyton binary with beancount installed
pythonPath = "python3",
};
};
},
},
docs = {
description = [[
https://github.com/polarmutex/beancount-language-server#installation
See https://github.com/polarmutex/beancount-language-server#configuration for configuration options
]];
]],
default_config = {
root_dir = [[root_pattern("elm.json")]];
};
};
root_dir = [[root_pattern("elm.json")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,14 +1,14 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.ccls = {
default_config = {
cmd = {"ccls"};
filetypes = {"c", "cpp", "objc", "objcpp"};
cmd = { "ccls" },
filetypes = { "c", "cpp", "objc", "objcpp" },
root_dir = function(fname)
return util.root_pattern("compile_commands.json", "compile_flags.txt", ".git")(fname) or util.path.dirname(fname)
end;
};
end,
},
docs = {
description = [[
https://github.com/MaskRay/ccls/wiki
@ -35,10 +35,10 @@ lspconfig.ccls.setup {
```
]];
]],
default_config = {
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]];
};
};
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,54 +1,60 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
local function switch_source_header(bufnr)
bufnr = util.validate_bufnr(bufnr)
local params = { uri = vim.uri_from_bufnr(bufnr) }
vim.lsp.buf_request(bufnr, 'textDocument/switchSourceHeader', params, function(err, _, result)
if err then error(tostring(err)) end
if not result then print ("Corresponding file cannot be determined") return end
vim.api.nvim_command('edit '..vim.uri_to_fname(result))
vim.lsp.buf_request(bufnr, "textDocument/switchSourceHeader", params, function(err, _, result)
if err then
error(tostring(err))
end
if not result then
print "Corresponding file cannot be determined"
return
end
vim.api.nvim_command("edit " .. vim.uri_to_fname(result))
end)
end
local root_pattern = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git")
local default_capabilities = vim.tbl_deep_extend(
'force',
util.default_config.capabilities or vim.lsp.protocol.make_client_capabilities(), {
textDocument = {
completion = {
editsNearCursor = true
}
},
offsetEncoding = {"utf-8", "utf-16"}
});
"force",
util.default_config.capabilities or vim.lsp.protocol.make_client_capabilities(),
{
textDocument = {
completion = {
editsNearCursor = true,
},
},
offsetEncoding = { "utf-8", "utf-16" },
}
)
configs.clangd = {
default_config = {
cmd = {"clangd", "--background-index"};
filetypes = {"c", "cpp", "objc", "objcpp"};
cmd = { "clangd", "--background-index" },
filetypes = { "c", "cpp", "objc", "objcpp" },
root_dir = function(fname)
local filename = util.path.is_absolute(fname) and fname
or util.path.join(vim.loop.cwd(), fname)
local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
return root_pattern(filename) or util.path.dirname(filename)
end;
end,
on_init = function(client, result)
if result.offsetEncoding then
client.offset_encoding = result.offsetEncoding
end
end;
capabilities = default_capabilities;
};
end,
capabilities = default_capabilities,
},
commands = {
ClangdSwitchSourceHeader = {
function()
switch_source_header(0)
end;
description = "Switch between source/header";
};
};
end,
description = "Switch between source/header",
},
},
docs = {
description = [[
https://clangd.llvm.org/installation.html
@ -58,13 +64,13 @@ https://clangd.llvm.org/installation.html
clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
as compile_commands.json or, for simpler projects, a compile_flags.txt.
For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html).
]];
]],
default_config = {
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]];
on_init = [[function to handle changing offsetEncoding]];
capabilities = [[default capabilities, with offsetEncoding utf-8]];
};
};
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
on_init = [[function to handle changing offsetEncoding]],
capabilities = [[default capabilities, with offsetEncoding utf-8]],
},
},
}
configs.clangd.switch_source_header = switch_source_header

View File

@ -1,22 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.clojure_lsp = {
default_config = {
cmd = {"clojure-lsp"};
filetypes = {"clojure", "edn"};
root_dir = util.root_pattern("project.clj", "deps.edn", ".git");
};
cmd = { "clojure-lsp" },
filetypes = { "clojure", "edn" },
root_dir = util.root_pattern("project.clj", "deps.edn", ".git"),
},
docs = {
description = [[
https://github.com/snoe/clojure-lsp
Clojure Language Server
]];
]],
default_config = {
root_dir = [[root_pattern("project.clj", "deps.edn", ".git")]];
};
};
root_dir = [[root_pattern("project.clj", "deps.edn", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,27 +1,27 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.cmake = {
default_config = {
cmd = {"cmake-language-server"};
filetypes = {"cmake"};
cmd = { "cmake-language-server" },
filetypes = { "cmake" },
root_dir = function(fname)
return util.root_pattern(".git", "compile_commands.json", "build")(fname) or util.path.dirname(fname)
end;
end,
init_options = {
buildDirectory = "build",
}
};
},
},
docs = {
description = [[
https://github.com/regen100/cmake-language-server
CMake LSP Implementation
]];
]],
default_config = {
root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]];
};
};
};
root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,51 +1,53 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "codeqlls"
local root_pattern = util.root_pattern("qlpack.yml")
local root_pattern = util.root_pattern "qlpack.yml"
configs[server_name] = {
default_config = {
cmd = {"codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q"};
filetypes = {'ql'};
root_dir = function(fname)
return root_pattern(fname) or util.path.dirname(fname)
end;
log_level = vim.lsp.protocol.MessageType.Warning;
before_init = function(initialize_params)
initialize_params['workspaceFolders'] = {{
name = 'workspace',
uri = initialize_params['rootUri']
}}
end;
settings = {
search_path = vim.empty_dict()
};
};
docs = {
description = [[
default_config = {
cmd = { "codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q" },
filetypes = { "ql" },
root_dir = function(fname)
return root_pattern(fname) or util.path.dirname(fname)
end,
log_level = vim.lsp.protocol.MessageType.Warning,
before_init = function(initialize_params)
initialize_params["workspaceFolders"] = {
{
name = "workspace",
uri = initialize_params["rootUri"],
},
}
end,
settings = {
search_path = vim.empty_dict(),
},
},
docs = {
description = [[
Reference:
https://help.semmle.com/codeql/codeql-cli.html
Binaries:
https://github.com/github/codeql-cli-binaries
]];
default_config = {
settings = {
search_path = [[list containing all search paths, eg: '~/codeql-home/codeql-repo']];
};
};
};
on_new_config = function(config)
if type(config.settings.search_path) == 'table' and not vim.tbl_isempty(config.settings.search_path) then
local search_path = "--search-path="
for _, path in ipairs(config.settings.search_path) do
search_path = search_path..vim.fn.expand(path)..":"
end
config.cmd = {"codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q", search_path}
else
config.cmd = {"codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q"}
end
end;
]],
default_config = {
settings = {
search_path = [[list containing all search paths, eg: '~/codeql-home/codeql-repo']],
},
},
},
on_new_config = function(config)
if type(config.settings.search_path) == "table" and not vim.tbl_isempty(config.settings.search_path) then
local search_path = "--search-path="
for _, path in ipairs(config.settings.search_path) do
search_path = search_path .. vim.fn.expand(path) .. ":"
end
config.cmd = { "codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q", search_path }
else
config.cmd = { "codeql", "execute", "language-server", "--check-errors", "ON_CHANGE", "-q" }
end
end,
}

View File

@ -1,4 +1,4 @@
local util = require 'lspconfig/util'
local util = require "lspconfig/util"
local api, validate, lsp = vim.api, vim.validate, vim.lsp
local tbl_extend = vim.tbl_extend
@ -6,17 +6,17 @@ local configs = {}
function configs.__newindex(t, config_name, config_def)
validate {
name = {config_name, 's'};
default_config = {config_def.default_config, 't'};
on_new_config = {config_def.on_new_config, 'f', true};
on_attach = {config_def.on_attach, 'f', true};
commands = {config_def.commands, 't', true};
name = { config_name, "s" },
default_config = { config_def.default_config, "t" },
on_new_config = { config_def.on_new_config, "f", true },
on_attach = { config_def.on_attach, "f", true },
commands = { config_def.commands, "t", true },
}
if config_def.commands then
for k, v in pairs(config_def.commands) do
validate {
['command.name'] = {k, 's'};
['command.fn'] = {v[1], 'f'};
["command.name"] = { k, "s" },
["command.fn"] = { v[1], "f" },
}
end
else
@ -32,18 +32,18 @@ function configs.__newindex(t, config_name, config_def)
function M.setup(config)
validate {
cmd = {config.cmd, 't', default_config.cmd ~= nil};
root_dir = {config.root_dir, 'f', default_config.root_dir ~= nil};
filetypes = {config.filetype, 't', true};
on_new_config = {config.on_new_config, 'f', true};
on_attach = {config.on_attach, 'f', true};
commands = {config.commands, 't', true};
cmd = { config.cmd, "t", default_config.cmd ~= nil },
root_dir = { config.root_dir, "f", default_config.root_dir ~= nil },
filetypes = { config.filetype, "t", true },
on_new_config = { config.on_new_config, "f", true },
on_attach = { config.on_attach, "f", true },
commands = { config.commands, "t", true },
}
if config.commands then
for k, v in pairs(config.commands) do
validate {
['command.name'] = {k, 's'};
['command.fn'] = {v[1], 'f'};
["command.name"] = { k, "s" },
["command.fn"] = { v[1], "f" },
}
end
end
@ -52,16 +52,12 @@ function configs.__newindex(t, config_name, config_def)
local trigger
if config.filetypes then
trigger = "FileType "..table.concat(config.filetypes, ',')
trigger = "FileType " .. table.concat(config.filetypes, ",")
else
trigger = "BufReadPost *"
end
if not (config.autostart == false) then
api.nvim_command(string.format(
"autocmd %s lua require'lspconfig'[%q].manager.try_add()"
, trigger
, config.name
))
api.nvim_command(string.format("autocmd %s lua require'lspconfig'[%q].manager.try_add()", trigger, config.name))
end
local get_root_dir = config.root_dir
@ -72,11 +68,13 @@ function configs.__newindex(t, config_name, config_def)
vim.notify(string.format("Autostart for %s failed: matching root directory not detected.", config_name))
return
end
api.nvim_command(string.format(
"autocmd %s lua require'lspconfig'[%q].manager.try_add_wrapper()"
, "BufReadPost " .. root_dir .. "/*"
, config.name
))
api.nvim_command(
string.format(
"autocmd %s lua require'lspconfig'[%q].manager.try_add_wrapper()",
"BufReadPost " .. root_dir .. "/*",
config.name
)
)
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local buf_dir = api.nvim_buf_get_name(bufnr)
if buf_dir:sub(1, root_dir:len()) == root_dir then
@ -103,12 +101,12 @@ function configs.__newindex(t, config_name, config_def)
local make_config = function(_root_dir)
local new_config = vim.tbl_deep_extend("keep", vim.empty_dict(), config)
new_config = vim.tbl_deep_extend('keep', new_config, default_config)
new_config = vim.tbl_deep_extend("keep", new_config, default_config)
new_config.capabilities = new_config.capabilities or lsp.protocol.make_client_capabilities()
new_config.capabilities = vim.tbl_deep_extend('keep', new_config.capabilities, {
new_config.capabilities = vim.tbl_deep_extend("keep", new_config.capabilities, {
workspace = {
configuration = true;
}
configuration = true,
},
})
if config_def.on_new_config then
@ -120,12 +118,14 @@ function configs.__newindex(t, config_name, config_def)
new_config.on_init = util.add_hook_after(new_config.on_init, function(client, _result)
function client.workspace_did_change_configuration(settings)
if not settings then return end
if vim.tbl_isempty(settings) then
settings = {[vim.type_idx]=vim.types.dictionary}
if not settings then
return
end
return client.notify('workspace/didChangeConfiguration', {
settings = settings;
if vim.tbl_isempty(settings) then
settings = { [vim.type_idx] = vim.types.dictionary }
end
return client.notify("workspace/didChangeConfiguration", {
settings = settings,
})
end
if not vim.tbl_isempty(new_config.settings) then
@ -139,13 +139,15 @@ function configs.__newindex(t, config_name, config_def)
if bufnr == api.nvim_get_current_buf() then
M._setup_buffer(client.id, bufnr)
else
api.nvim_command(string.format(
"autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)"
, bufnr
, config_name
, client.id
, bufnr
))
api.nvim_command(
string.format(
"autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
bufnr,
config_name,
client.id,
bufnr
)
)
end
end)
@ -159,7 +161,7 @@ function configs.__newindex(t, config_name, config_def)
function manager.try_add(bufnr)
bufnr = bufnr or api.nvim_get_current_buf()
if vim.api.nvim_buf_get_option(bufnr, 'filetype') == 'nofile' then
if vim.api.nvim_buf_get_option(bufnr, "filetype") == "nofile" then
return
end
local root_dir = get_root_dir(api.nvim_buf_get_name(bufnr), bufnr)
@ -170,7 +172,7 @@ function configs.__newindex(t, config_name, config_def)
end
function manager.try_add_wrapper(bufnr)
local buftype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
local buftype = vim.api.nvim_buf_get_option(bufnr, "filetype")
for _, filetype in ipairs(config.filetypes) do
if buftype == filetype then
manager.try_add(bufnr)

View File

@ -1,24 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.crystalline = {
default_config = {
cmd = {'crystalline'},
filetypes = {'crystal'},
cmd = { "crystalline" },
filetypes = { "crystal" },
root_dir = function(fname)
return util.root_pattern('shard.yml')(fname) or
util.find_git_ancestor(fname) or
util.path.dirname(fname)
end
return util.root_pattern "shard.yml"(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
},
docs = {
description = [[
description = [[
https://github.com/elbywan/crystalline
Crystal language server.
]],
default_config = {
root_dir = [[root_pattern('shard.yml', '.git') or dirname]]
}
}
default_config = {
root_dir = [[root_pattern('shard.yml', '.git') or dirname]],
},
},
}

View File

@ -1,24 +1,24 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "cssls"
local bin_name = "vscode-css-language-server"
local root_pattern = util.root_pattern("package.json")
local root_pattern = util.root_pattern "package.json"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"css", "scss", "less"};
cmd = { bin_name, "--stdio" },
filetypes = { "css", "scss", "less" },
root_dir = function(fname)
return root_pattern(fname) or vim.loop.os_homedir()
end;
end,
settings = {
css = { validate = true },
scss = { validate = true },
less = { validate = true }
};
};
less = { validate = true },
},
},
docs = {
description = [[
@ -41,11 +41,11 @@ require'lspconfig'.cssls.setup {
capabilities = capabilities,
}
```
]];
]],
default_config = {
root_dir = [[root_pattern("package.json")]];
};
};
root_dir = [[root_pattern("package.json")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,26 +1,26 @@
local util = require 'lspconfig/util'
local configs = require 'lspconfig/configs'
local util = require "lspconfig/util"
local configs = require "lspconfig/configs"
local server_name = "dartls"
local bin_name = "dart"
local find_dart_sdk_root_path = function()
if vim.fn["executable"]("flutter") == 1 then
local flutter_path = vim.fn["resolve"](vim.fn["exepath"]("flutter"))
if vim.fn["executable"] "flutter" == 1 then
local flutter_path = vim.fn["resolve"](vim.fn["exepath"] "flutter")
local flutter_bin = vim.fn["fnamemodify"](flutter_path, ":h")
return flutter_bin.."/cache/dart-sdk/bin/dart"
elseif vim.fn["executable"]("dart") == 1 then
return vim.fn["resolve"](vim.fn["exepath"]("dart"))
return flutter_bin .. "/cache/dart-sdk/bin/dart"
elseif vim.fn["executable"] "dart" == 1 then
return vim.fn["resolve"](vim.fn["exepath"] "dart")
else
return ''
return ""
end
end
local analysis_server_snapshot_path = function()
local dart_sdk_root_path = vim.fn["fnamemodify"](find_dart_sdk_root_path(), ":h")
local snapshot = dart_sdk_root_path.."/snapshots/analysis_server.dart.snapshot"
local snapshot = dart_sdk_root_path .. "/snapshots/analysis_server.dart.snapshot"
if vim.fn["has"]("win32") == 1 or vim.fn["has"]("win64") == 1 then
if vim.fn["has"] "win32" == 1 or vim.fn["has"] "win64" == 1 then
snapshot = snapshot:gsub("/", "\\")
end
@ -29,27 +29,27 @@ end
configs[server_name] = {
default_config = {
cmd = {bin_name, analysis_server_snapshot_path(), "--lsp"};
filetypes = {"dart"};
root_dir = util.root_pattern("pubspec.yaml");
cmd = { bin_name, analysis_server_snapshot_path(), "--lsp" },
filetypes = { "dart" },
root_dir = util.root_pattern "pubspec.yaml",
init_options = {
onlyAnalyzeProjectsWithOpenFiles = false,
suggestFromUnimportedLibraries = true,
closingLabels = false,
outline = false,
flutterOutline = false
};
};
flutterOutline = false,
},
},
docs = {
package_json = "https://raw.githubusercontent.com/Dart-Code/Dart-Code/master/package.json";
package_json = "https://raw.githubusercontent.com/Dart-Code/Dart-Code/master/package.json",
description = [[
https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec
Language server for dart.
]];
]],
default_config = {
root_dir = [[root_pattern("pubspec.yaml")]];
};
};
};
root_dir = [[root_pattern("pubspec.yaml")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,5 +1,5 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local lsp = vim.lsp
local server_name = "denols"
@ -27,19 +27,25 @@ local function buf_cache(bufnr)
params["referrer"] = { uri = vim.uri_from_bufnr(bufnr) }
params["uris"] = {}
lsp.buf_request(bufnr, "deno/cache", params, function(err)
if err then error(tostring(err)) end
if err then
error(tostring(err))
end
end)
end
local function virtual_text_document_handler(uri, result)
if not result then return nil end
if not result then
return nil
end
for client_id, res in pairs(result) do
local lines = vim.split(res.result, "\n")
local bufnr = vim.uri_to_bufnr(deno_uri_to_uri(uri))
local current_buf = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
if #current_buf ~= 0 then return nil end
if #current_buf ~= 0 then
return nil
end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
vim.api.nvim_buf_set_option(bufnr, "readonly", true)
@ -60,14 +66,16 @@ local function virtual_text_document(uri)
end
local function denols_handler(err, method, result)
if not result or vim.tbl_isempty(result) then return nil end
if not result or vim.tbl_isempty(result) then
return nil
end
for _, res in pairs(result) do
local uri = res.uri or res.targetUri
if string.sub(uri, 1, 6) == "deno:/" then
virtual_text_document(uri)
res['uri'] = deno_uri_to_uri(uri)
res['targetUri'] = deno_uri_to_uri(uri)
res["uri"] = deno_uri_to_uri(uri)
res["targetUri"] = deno_uri_to_uri(uri)
end
end
@ -81,59 +89,59 @@ local function denols_definition()
end
local function denols_references(context)
vim.validate { context = { context, 't', true } }
vim.validate { context = { context, "t", true } }
local params = lsp.util.make_position_params()
params.context = context or {
includeDeclaration = true;
includeDeclaration = true,
}
params[vim.type_idx] = vim.types.dictionary
params.textDocument.uri = uri_to_deno_uri(params.textDocument.uri)
lsp.buf_request(0, 'textDocument/references', params)
lsp.buf_request(0, "textDocument/references", params)
end
configs[server_name] = {
default_config = {
cmd = {"deno", "lsp"};
filetypes = {"javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx"};
root_dir = util.root_pattern("package.json", "tsconfig.json", ".git");
cmd = { "deno", "lsp" },
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
root_dir = util.root_pattern("package.json", "tsconfig.json", ".git"),
init_options = {
enable = true;
lint = false;
unstable = false;
};
enable = true,
lint = false,
unstable = false,
},
handlers = {
["textDocument/definition"] = denols_handler;
["textDocument/references"] = denols_handler;
};
};
["textDocument/definition"] = denols_handler,
["textDocument/references"] = denols_handler,
},
},
commands = {
DenolsDefinition = {
denols_definition;
description = "Jump to definition. This handle deno:/ schema in deno:// buffer."
};
denols_definition,
description = "Jump to definition. This handle deno:/ schema in deno:// buffer.",
},
DenolsReferences = {
function()
denols_references({ includeDeclaration = true })
end;
description = "List references. This handle deno:/ schema in deno:// buffer."
};
denols_references { includeDeclaration = true }
end,
description = "List references. This handle deno:/ schema in deno:// buffer.",
},
DenolsCache = {
function()
buf_cache(0)
end;
description = "Cache a module and all of its dependencies."
};
};
end,
description = "Cache a module and all of its dependencies.",
},
},
docs = {
description = [[
https://github.com/denoland/deno
Deno's built-in language server
]];
]],
default_config = {
root_dir = [[root_pattern("package.json", "tsconfig.json", ".git")]];
};
};
root_dir = [[root_pattern("package.json", "tsconfig.json", ".git")]],
},
},
}
configs.denols.definition = denols_definition

View File

@ -1,11 +1,11 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.dhall_lsp_server ={
configs.dhall_lsp_server = {
default_config = {
cmd = {"dhall-lsp-server"};
filetypes = {"dhall"};
root_dir = util.root_pattern(".git", vim.fn.getcwd());
cmd = { "dhall-lsp-server" },
filetypes = { "dhall" },
root_dir = util.root_pattern(".git", vim.fn.getcwd()),
docs = {
description = [[
https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-lsp-server
@ -17,10 +17,10 @@ language server for dhall
cabal install dhall-lsp-server
```
prebuilt binaries can be found [here](https://github.com/dhall-lang/dhall-haskell/releases).
]];
]],
default_config = {
root_dir = [[root_pattern(".git", vim.fn.getcwd())]];
};
}
}
root_dir = [[root_pattern(".git", vim.fn.getcwd())]],
},
},
},
}

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "diagnosticls"
local bin_name = "diagnostic-languageserver"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"},
cmd = { bin_name, "--stdio" },
filetypes = {},
root_dir = util.path.dirname,
},
@ -15,11 +15,11 @@ configs[server_name] = {
https://github.com/iamcco/diagnostic-languageserver
Diagnostic language server integrate with linters.
]];
]],
default_config = {
filetypes = "Empty by default, override to add filetypes",
root_dir = "Vim's starting directory";
init_options = "Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document";
};
};
root_dir = "Vim's starting directory",
init_options = "Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document",
},
},
}

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "dockerls"
local bin_name = "docker-langserver"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"Dockerfile", "dockerfile"};
root_dir = util.root_pattern("Dockerfile");
};
cmd = { bin_name, "--stdio" },
filetypes = { "Dockerfile", "dockerfile" },
root_dir = util.root_pattern "Dockerfile",
},
docs = {
description = [[
https://github.com/rcjsuen/dockerfile-language-server-nodejs
@ -18,11 +18,11 @@ https://github.com/rcjsuen/dockerfile-language-server-nodejs
```sh
npm install -g dockerfile-language-server-nodejs
```
]];
]],
default_config = {
root_dir = [[root_pattern("Dockerfile")]];
};
};
};
root_dir = [[root_pattern("Dockerfile")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,22 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "dotls"
local bin_name = "dot-language-server"
local root_files = {
'.git',
".git",
}
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"dot"};
cmd = { bin_name, "--stdio" },
filetypes = { "dot" },
root_dir = function(filename)
return util.root_pattern(unpack(root_files))(filename) or
util.path.dirname(filename)
end;
};
return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename)
end,
},
docs = {
description = [[
https://github.com/nikeee/dot-language-server
@ -25,8 +24,8 @@ https://github.com/nikeee/dot-language-server
```sh
npm install -g dot-language-server
```
]];
};
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,27 +1,26 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "efm"
local bin_name = "efm-langserver"
configs[server_name] = {
default_config = {
cmd = {bin_name};
cmd = { bin_name },
root_dir = function(fname)
return util.root_pattern(".git")(fname) or util.path.dirname(fname)
end;
};
return util.root_pattern ".git"(fname) or util.path.dirname(fname)
end,
},
docs = {
description = [[
https://github.com/mattn/efm-langserver
General purpose Language Server that can use specified error message format generated from specified command.
]];
]],
default_config = {
root_dir = [[util.root_pattern(".git")(fname) or util.path.dirname(fname)]];
};
};
root_dir = [[util.root_pattern(".git")(fname) or util.path.dirname(fname)]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,17 +1,17 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "elixirls"
configs[server_name] = {
default_config = {
filetypes = {"elixir", "eelixir"};
filetypes = { "elixir", "eelixir" },
root_dir = function(fname)
return util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir()
end;
};
docs = {
package_json = "https://raw.githubusercontent.com/JakeBecker/vscode-elixir-ls/master/package.json";
description = [[
return util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir()
end,
},
docs = {
package_json = "https://raw.githubusercontent.com/JakeBecker/vscode-elixir-ls/master/package.json",
description = [[
https://github.com/elixir-lsp/elixir-ls
`elixir-ls` can be installed by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running).
@ -34,11 +34,11 @@ require'lspconfig'.elixirls.setup{
...
}
```
]];
default_config = {
root_dir = [[root_pattern("mix.exs", ".git") or vim.loop.os_homedir()]];
};
};
]],
default_config = {
root_dir = [[root_pattern("mix.exs", ".git") or vim.loop.os_homedir()]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,5 +1,5 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local lsp = vim.lsp
local api = vim.api
@ -7,29 +7,29 @@ local server_name = "elmls"
local bin_name = "elm-language-server"
local default_capabilities = lsp.protocol.make_client_capabilities()
default_capabilities.offsetEncoding = {"utf-8", "utf-16"}
local elm_root_pattern = util.root_pattern("elm.json")
default_capabilities.offsetEncoding = { "utf-8", "utf-16" }
local elm_root_pattern = util.root_pattern "elm.json"
configs[server_name] = {
default_config = {
cmd = {bin_name};
cmd = { bin_name },
-- TODO(ashkan) if we comment this out, it will allow elmls to operate on elm.json. It seems like it could do that, but no other editor allows it right now.
filetypes = {"elm"};
filetypes = { "elm" },
root_dir = function(fname)
local filetype = api.nvim_buf_get_option(0, 'filetype')
if filetype == 'elm' or (filetype == 'json' and fname:match("elm%.json$")) then
local filetype = api.nvim_buf_get_option(0, "filetype")
if filetype == "elm" or (filetype == "json" and fname:match "elm%.json$") then
return elm_root_pattern(fname)
end
end;
end,
init_options = {
elmPath = "elm",
elmFormatPath = "elm-format",
elmTestPath = "elm-test",
elmAnalyseTrigger = "change",
};
};
},
},
docs = {
package_json = "https://raw.githubusercontent.com/elm-tooling/elm-language-client-vscode/master/package.json";
package_json = "https://raw.githubusercontent.com/elm-tooling/elm-language-client-vscode/master/package.json",
description = [[
https://github.com/elm-tooling/elm-language-server#installation
@ -37,12 +37,11 @@ If you don't want to use Nvim to install it, then you can use:
```sh
npm install -g elm elm-test elm-format @elm-tooling/elm-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("elm.json")]];
};
};
root_dir = [[root_pattern("elm.json")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,14 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.erlangls = {
default_config = {
cmd = { "erlang_ls" };
filetypes = { "erlang" };
cmd = { "erlang_ls" },
filetypes = { "erlang" },
root_dir = function(fname)
return util.root_pattern("rebar.config", "erlang.mk", ".git")(fname) or util.path.dirname(fname)
end;
};
end,
},
docs = {
description = [[
https://erlang-ls.github.io
@ -24,9 +23,9 @@ Installation instruction can be found [here](https://github.com/erlang-ls/erlang
Installation requirements:
- [Erlang OTP 21+](https://github.com/erlang/otp)
- [rebar3 3.9.1+](https://github.com/erlang/rebar3)
]];
]],
default_config = {
root_dir = [[root_pattern('rebar.config', 'erlang.mk', '.git') or util.path.dirname(fname)]]
}
};
root_dir = [[root_pattern('rebar.config', 'erlang.mk', '.git') or util.path.dirname(fname)]],
},
},
}

View File

@ -1,14 +1,14 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.flow = {
default_config = {
cmd = {"npx", "--no-install", "flow","lsp"};
filetypes = {"javascript", "javascriptreact", "javascript.jsx"};
root_dir = util.root_pattern(".flowconfig");
};
cmd = { "npx", "--no-install", "flow", "lsp" },
filetypes = { "javascript", "javascriptreact", "javascript.jsx" },
root_dir = util.root_pattern ".flowconfig",
},
docs = {
package_json = "https://raw.githubusercontent.com/flowtype/flow-for-vscode/master/package.json";
package_json = "https://raw.githubusercontent.com/flowtype/flow-for-vscode/master/package.json",
description = [[
https://flow.org/
https://github.com/facebook/flow
@ -21,10 +21,10 @@ See below for lsp command options.
```sh
npx flow lsp --help
```
]];
]],
default_config = {
root_dir = [[root_pattern(".flowconfig")]];
};
};
};
root_dir = [[root_pattern(".flowconfig")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,25 +1,25 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.fortls = {
default_config = {
cmd = {"fortls"};
filetypes = {"fortran"};
root_dir = util.root_pattern(".fortls");
cmd = { "fortls" },
filetypes = { "fortran" },
root_dir = util.root_pattern ".fortls",
settings = {
nthreads = 1,
};
};
},
},
docs = {
package_json = "https://raw.githubusercontent.com/hansec/vscode-fortran-ls/master/package.json";
package_json = "https://raw.githubusercontent.com/hansec/vscode-fortran-ls/master/package.json",
description = [[
https://github.com/hansec/fortran-language-server
Fortran Language Server for the Language Server Protocol
]];
]],
default_config = {
root_dir = [[root_pattern(".fortls")]];
};
};
};
root_dir = [[root_pattern(".fortls")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,17 +1,17 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "fsautocomplete"
configs[server_name] = {
default_config = {
cmd = {'dotnet', 'fsautocomplete', '--background-service-enabled'};
root_dir = util.root_pattern('*.sln', '*.fsproj', '.git');
filetypes = {'fsharp'};
cmd = { "dotnet", "fsautocomplete", "--background-service-enabled" },
root_dir = util.root_pattern("*.sln", "*.fsproj", ".git"),
filetypes = { "fsharp" },
init_options = {
AutomaticWorkspaceInit = true;
};
};
AutomaticWorkspaceInit = true,
},
},
docs = {
description = [[
https://github.com/fsharp/FsAutoComplete
@ -30,7 +30,7 @@ You may also need to configure the filetype as Vim defaults to Forth for `*.fs`
This is automatically done by plugins such as [PhilT/vim-fsharp](https://github.com/PhilT/vim-fsharp), [fsharp/vim-fsharp](https://github.com/fsharp/vim-fsharp), and [adelarsq/neofsharp.vim](https://github.com/adelarsq/neofsharp.vim).
]];
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,22 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.gdscript = {
default_config = {
cmd = {"nc", "localhost", "6008"};
filetypes = {"gd", "gdscript", "gdscript3"};
root_dir = util.root_pattern("project.godot", ".git");
};
cmd = { "nc", "localhost", "6008" },
filetypes = { "gd", "gdscript", "gdscript3" },
root_dir = util.root_pattern("project.godot", ".git"),
},
docs = {
description = [[
https://github.com/godotengine/godot
Language server for GDScript, used by Godot Engine.
]];
]],
default_config = {
root_dir = [[util.root_pattern("project.godot", ".git")]];
};
};
};
root_dir = [[util.root_pattern("project.godot", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.ghcide = {
default_config = {
cmd = { "ghcide", "--lsp" };
filetypes = { "haskell", "lhaskell" };
root_dir = util.root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml");
};
cmd = { "ghcide", "--lsp" },
filetypes = { "haskell", "lhaskell" },
root_dir = util.root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml"),
},
docs = {
description = [[
@ -14,10 +14,10 @@ https://github.com/digital-asset/ghcide
A library for building Haskell IDE tooling.
"ghcide" isn't for end users now. Use "haskell-language-server" instead of "ghcide".
]];
]],
default_config = {
root_dir = [[root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml")]];
};
};
};
root_dir = [[root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.gopls = {
default_config = {
cmd = {"gopls"};
filetypes = {"go", "gomod"};
root_dir = util.root_pattern("go.mod", ".git");
};
cmd = { "gopls" },
filetypes = { "go", "gomod" },
root_dir = util.root_pattern("go.mod", ".git"),
},
-- on_new_config = function(new_config) end;
-- on_attach = function(client, bufnr) end;
docs = {
@ -14,10 +14,10 @@ configs.gopls = {
https://github.com/golang/tools/tree/master/gopls
Google's lsp server for golang.
]];
]],
default_config = {
root_dir = [[root_pattern("go.mod", ".git")]];
};
};
root_dir = [[root_pattern("go.mod", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,14 +1,14 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = 'graphql'
local bin_name = 'graphql-lsp'
local server_name = "graphql"
local bin_name = "graphql-lsp"
configs[server_name] = {
default_config = {
cmd = {bin_name, 'server', '-m', 'stream'},
filetypes = {'graphql'},
root_dir = util.root_pattern('.git', '.graphqlrc'),
cmd = { bin_name, "server", "-m", "stream" },
filetypes = { "graphql" },
root_dir = util.root_pattern(".git", ".graphqlrc"),
},
docs = {

View File

@ -1,5 +1,5 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local name = "groovyls"
local bin_name = "groovy-language-server-all.jar"
@ -7,11 +7,13 @@ local bin_name = "groovy-language-server-all.jar"
configs[name] = {
default_config = {
cmd = {
"java", "-jar", bin_name
"java",
"-jar",
bin_name,
},
filetypes = {"groovy"};
root_dir = util.root_pattern(".git") or vim.loop.os_homedir();
};
filetypes = { "groovy" },
root_dir = util.root_pattern ".git" or vim.loop.os_homedir(),
},
docs = {
description = [[
https://github.com/prominic/groovy-language-server.git
@ -31,15 +33,17 @@ require'lspconfig'.groovyls.setup{
...
}
```
]];
]],
default_config = {
cmd = {
"java", "-jar", bin_name
"java",
"-jar",
bin_name,
},
filetypes = {"groovy"};
root_dir = [[root_pattern(".git") or vim.loop.os_homedir()]];
};
};
filetypes = { "groovy" },
root_dir = [[root_pattern(".git") or vim.loop.os_homedir()]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,20 +1,20 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.haxe_language_server = {
default_config = {
cmd = {"haxe-language-server"};
filetypes = {"haxe"};
root_dir = util.root_pattern("*.hxml");
cmd = { "haxe-language-server" },
filetypes = { "haxe" },
root_dir = util.root_pattern "*.hxml",
settings = {
haxe = {
executable = "haxe";
};
};
executable = "haxe",
},
},
init_options = {
displayArguments = {"build.hxml"};
};
};
displayArguments = { "build.hxml" },
},
},
docs = {
description = [[
https://github.com/vshaxe/haxe-language-server
@ -42,7 +42,7 @@ your project's root directory. If your file is named something different,
specify it using the `init_options.displayArguments` setting.
]],
default_config = {
root_dir = [[root_pattern("*.hxml")]];
};
}
root_dir = [[root_pattern("*.hxml")]],
},
},
}

View File

@ -1,21 +1,21 @@
local M = {}
function M.check_health()
local configs = require 'lspconfig/configs'
local configs = require "lspconfig/configs"
for _, top_level_config in pairs(configs) do
-- Only check configs that have a make_config function.
if not (top_level_config.make_config == nil) then
-- the folder needs to exist
local config = top_level_config.make_config(".")
local config = top_level_config.make_config "."
local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd)
if not status then
vim.fn['health#report_error'](string.format("%s: config.cmd error, %s", config.name, cmd))
vim.fn["health#report_error"](string.format("%s: config.cmd error, %s", config.name, cmd))
else
if not (vim.fn.executable(cmd) == 1) then
vim.fn['health#report_error'](string.format("%s: The given command %q is not executable.", config.name, cmd))
vim.fn["health#report_error"](string.format("%s: The given command %q is not executable.", config.name, cmd))
else
vim.fn['health#report_info'](string.format("%s: configuration checked.", config.name))
vim.fn["health#report_info"](string.format("%s: configuration checked.", config.name))
end
end
end

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.hie = {
default_config = {
cmd = {"hie-wrapper", "--lsp"};
filetypes = {"haskell"};
root_dir = util.root_pattern("stack.yaml", "package.yaml", ".git");
};
cmd = { "hie-wrapper", "--lsp" },
filetypes = { "haskell" },
root_dir = util.root_pattern("stack.yaml", "package.yaml", ".git"),
},
docs = {
package_json = "https://raw.githubusercontent.com/alanz/vscode-hie-server/master/package.json";
package_json = "https://raw.githubusercontent.com/alanz/vscode-hie-server/master/package.json",
description = [[
https://github.com/haskell/haskell-ide-engine
@ -27,12 +27,12 @@ init_options = {
}
}
```
]];
]],
default_config = {
root_dir = [[root_pattern("stack.yaml", "package.yaml", ".git")]];
};
};
};
root_dir = [[root_pattern("stack.yaml", "package.yaml", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,36 +1,36 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.hls = {
default_config = {
cmd = {"haskell-language-server-wrapper", "--lsp"};
filetypes = {"haskell", "lhaskell"};
root_dir = util.root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml");
cmd = { "haskell-language-server-wrapper", "--lsp" },
filetypes = { "haskell", "lhaskell" },
root_dir = util.root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"),
settings = {
languageServerHaskell = {
formattingProvider = "ormolu";
};
};
lspinfo = function (cfg)
formattingProvider = "ormolu",
},
},
lspinfo = function(cfg)
-- return "specific"
if cfg.settings.languageServerHaskell.logFile or false then
return "logfile: "..cfg.settings.languageServerHaskell.logFile
return "logfile: " .. cfg.settings.languageServerHaskell.logFile
end
return ""
end;
};
end,
},
docs = {
description = [[
https://github.com/haskell/haskell-language-server
Haskell Language Server
]];
]],
default_config = {
root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]];
};
};
};
root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,25 +1,24 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "html"
local bin_name = "vscode-html-language-server"
local root_pattern = util.root_pattern("package.json")
local root_pattern = util.root_pattern "package.json"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"html"};
cmd = { bin_name, "--stdio" },
filetypes = { "html" },
root_dir = function(fname)
return root_pattern(fname) or vim.loop.os_homedir()
end;
settings = {};
end,
settings = {},
init_options = {
embeddedLanguages = { css= true, javascript= true },
configurationSection = { 'html', 'css', 'javascript' },
}
};
embeddedLanguages = { css = true, javascript = true },
configurationSection = { "html", "css", "javascript" },
},
},
docs = {
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
@ -41,8 +40,8 @@ require'lspconfig'.html.setup {
capabilities = capabilities,
}
```
]];
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,21 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "intelephense"
local bin_name = "intelephense"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"php"};
root_dir = function (pattern)
local cwd = vim.loop.cwd();
local root = util.root_pattern("composer.json", ".git")(pattern);
cmd = { bin_name, "--stdio" },
filetypes = { "php" },
root_dir = function(pattern)
local cwd = vim.loop.cwd()
local root = util.root_pattern("composer.json", ".git")(pattern)
-- prefer cwd if root is a descendant
return util.path.is_descendant(cwd, root) and cwd or root;
end;
};
return util.path.is_descendant(cwd, root) and cwd or root
end,
},
docs = {
description = [[
https://intelephense.com/
@ -24,16 +24,16 @@ https://intelephense.com/
```sh
npm install -g intelephense
```
]];
]],
default_config = {
root_dir = [[root_pattern("composer.json", ".git")]];
root_dir = [[root_pattern("composer.json", ".git")]],
init_options = [[{
storagePath = Optional absolute path to storage dir. Defaults to os.tmpdir().
globalStoragePath = Optional absolute path to a global storage dir. Defaults to os.homedir().
licenceKey = Optional licence key or absolute path to a text file containing the licence key.
clearCache = Optional flag to clear server state. State can also be cleared by deleting {storagePath}/intelephense
-- See https://github.com/bmewburn/intelephense-docs#initialisation-options
}]];
}]],
settings = [[{
intelephense = {
files = {
@ -41,9 +41,9 @@ npm install -g intelephense
};
};
-- See https://github.com/bmewburn/intelephense-docs#configuration-options
}]];
};
};
}]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,15 @@
local lspconfig = require('lspconfig')
local configs = require('lspconfig/configs')
local lspconfig = require "lspconfig"
local configs = require "lspconfig/configs"
local name = 'java_language_server'
local name = "java_language_server"
configs[name] = {
default_config = {
cmd = {};
filetypes = {'java'};
root_dir = lspconfig.util.root_pattern('build.gradle', 'pom.xml', '.git');
settings = {}
};
cmd = {},
filetypes = { "java" },
root_dir = lspconfig.util.root_pattern("build.gradle", "pom.xml", ".git"),
settings = {},
},
docs = {
description = [[
https://github.com/georgewfraser/java-language-server
@ -17,6 +17,6 @@ https://github.com/georgewfraser/java-language-server
Java language server
Point `cmd` to `lang_server_linux.sh` or the equivalent script for macOS/Windows provided by java-language-server
]]
}
]],
},
}

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local handlers = require 'vim.lsp.handlers'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local handlers = require "vim.lsp.handlers"
local path = util.path
local server_name = "jdtls"
local cmd = {
util.path.join(tostring(vim.fn.getenv("JAVA_HOME")), "/bin/java"),
util.path.join(tostring(vim.fn.getenv "JAVA_HOME"), "/bin/java"),
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
@ -15,17 +15,16 @@ local cmd = {
"-Xms1g",
"-Xmx2G",
"-jar",
tostring(vim.fn.getenv("JAR")),
tostring(vim.fn.getenv "JAR"),
"-configuration",
tostring(vim.fn.getenv("JDTLS_CONFIG")),
tostring(vim.fn.getenv "JDTLS_CONFIG"),
"-data",
tostring(vim.fn.getenv("WORKSPACE")),
tostring(vim.fn.getenv "WORKSPACE"),
"--add-modules=ALL-SYSTEM",
"--add-opens java.base/java.util=ALL-UNNAMED",
"--add-opens java.base/java.lang=ALL-UNNAMED",
}
--- The presence of one of these files indicates a root directory.
--
-- We search for configuration files of the most common Java build systems. We
@ -34,16 +33,15 @@ local cmd = {
local root_files = {
-- Single-module projects
{
'build.xml', -- Ant
'pom.xml', -- Maven
'settings.gradle', -- Gradle
'settings.gradle.kts', -- Gradle
"build.xml", -- Ant
"pom.xml", -- Maven
"settings.gradle", -- Gradle
"settings.gradle.kts", -- Gradle
},
-- Multi-module projects
{'build.gradle', 'build.gradle.kts'},
{ "build.gradle", "build.gradle.kts" },
}
--- Callback function for the `language/status` notification.
--
-- The server sends a non-standard notification when the status of the language
@ -51,9 +49,9 @@ local root_files = {
-- starting up.
local function on_language_status(_, _, result)
local command = vim.api.nvim_command
command('echohl ModeMsg')
command "echohl ModeMsg"
command(string.format('echo "%s"', result.message))
command('echohl None')
command "echohl None"
end
-- If the text document version is 0, set it to nil instead so that Neovim
@ -75,22 +73,24 @@ configs[server_name] = {
default_config = {
cmd = cmd,
cmd_env = {
JAR=vim.fn.getenv("JAR"),
GRADLE_HOME=vim.fn.getenv("GRADLE_HOME"),
JAR = vim.fn.getenv "JAR",
GRADLE_HOME = vim.fn.getenv "GRADLE_HOME",
},
filetypes = { "java" };
filetypes = { "java" },
root_dir = function(fname)
for _, patterns in ipairs(root_files) do
local root = util.root_pattern(unpack(patterns))(fname)
if root then return root end
if root then
return root
end
end
return vim.fn.getcwd()
end;
end,
init_options = {
workspace = path.join { vim.loop.os_homedir(), "workspace" };
jvm_args = {};
os_config = nil;
};
workspace = path.join { vim.loop.os_homedir(), "workspace" },
jvm_args = {},
os_config = nil,
},
handlers = {
-- Due to an invalid protocol implementation in the jdtls we have to
-- conform these to be spec compliant.
@ -99,33 +99,33 @@ configs[server_name] = {
-- CodeAction in org.eclipse.lsp4j -> https://github.com/eclipse/lsp4j/blob/master/org.eclipse.lsp4j/src/main/xtend-gen/org/eclipse/lsp4j/CodeAction.java
-- Command in LSP -> https://microsoft.github.io/language-server-protocol/specification#command
-- CodeAction in LSP -> https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction
['textDocument/codeAction'] = function(a, b, actions)
for _,action in ipairs(actions) do
["textDocument/codeAction"] = function(a, b, actions)
for _, action in ipairs(actions) do
-- TODO: (steelsojka) Handle more than one edit?
-- if command is string, then 'ation' is Command in java format,
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
if action.command == 'java.apply.workspaceEdit' then
if action.command == "java.apply.workspaceEdit" then
action.edit = fix_zero_version(action.edit or action.arguments[1])
-- if command is table, then 'action' is CodeAction in java format
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
elseif type(action.command) == 'table' and action.command.command == 'java.apply.workspaceEdit' then
-- if command is table, then 'action' is CodeAction in java format
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
elseif type(action.command) == "table" and action.command.command == "java.apply.workspaceEdit" then
action.edit = fix_zero_version(action.edit or action.command.arguments[1])
end
end
handlers['textDocument/codeAction'](a, b, actions)
end;
handlers["textDocument/codeAction"](a, b, actions)
end,
['textDocument/rename'] = function(a, b, workspace_edit)
handlers['textDocument/rename'](a, b, fix_zero_version(workspace_edit))
end;
["textDocument/rename"] = function(a, b, workspace_edit)
handlers["textDocument/rename"](a, b, fix_zero_version(workspace_edit))
end,
['workspace/applyEdit'] = function(a, b, workspace_edit)
handlers['workspace/applyEdit'](a, b, fix_zero_version(workspace_edit))
end;
["workspace/applyEdit"] = function(a, b, workspace_edit)
handlers["workspace/applyEdit"](a, b, fix_zero_version(workspace_edit))
end,
['language/status'] = vim.schedule_wrap(on_language_status)
};
};
["language/status"] = vim.schedule_wrap(on_language_status),
},
},
docs = {
package_json = "https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json",
description = [[
@ -146,9 +146,9 @@ export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")
export JDTLS_CONFIG=/path/to/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux
export WORKSPACE=$HOME/workspace
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git")]];
};
};
root_dir = [[root_pattern(".git")]],
},
},
}

View File

@ -1,22 +1,22 @@
local configs = require 'lspconfig/configs'
local configs = require "lspconfig/configs"
configs.jedi_language_server = {
default_config = {
cmd = {"jedi-language-server"};
filetypes = {"python"};
cmd = { "jedi-language-server" },
filetypes = { "python" },
root_dir = function(fname)
return vim.fn.getcwd()
end;
};
end,
},
docs = {
description = [[
https://github.com/pappasam/jedi-language-server
`jedi-language-server`, a language server for Python, built on top of jedi
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,21 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "jsonls"
local bin_name = "vscode-json-language-server"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"json"};
cmd = { bin_name, "--stdio" },
filetypes = { "json" },
init_options = {
provideFormatter = true;
};
root_dir = util.root_pattern(".git", vim.fn.getcwd());
};
provideFormatter = true,
},
root_dir = util.root_pattern(".git", vim.fn.getcwd()),
},
docs = {
-- this language server config is in VSCode built-in package.json
package_json = "https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json";
package_json = "https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json",
description = [[
https://github.com/hrsh7th/vscode-langservers-extracted
@ -39,11 +39,11 @@ require'lspconfig'.jsonls.setup {
}
}
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git", vim.fn.getcwd())]];
};
};
root_dir = [[root_pattern(".git", vim.fn.getcwd())]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,11 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local cmd = {
"julia",
"--startup-file=no",
"--history-file=no",
"-e", [[
"-e",
[[
using Pkg;
Pkg.instantiate()
using LanguageServer; using SymbolServer;
@ -16,25 +17,25 @@ local cmd = {
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path);
server.runlinter = true;
run(server);
]]
};
]],
}
configs.julials = {
default_config = {
cmd = cmd;
cmd = cmd,
on_new_config = function(new_config, _)
local server_path = vim.fn.system("julia --startup-file=no -q -e 'print(Base.find_package(\"LanguageServer\"))'")
local server_path = vim.fn.system "julia --startup-file=no -q -e 'print(Base.find_package(\"LanguageServer\"))'"
local new_cmd = vim.deepcopy(cmd)
table.insert(new_cmd, 2, "--project="..server_path:sub(0,-19))
table.insert(new_cmd, 2, "--project=" .. server_path:sub(0, -19))
new_config.cmd = new_cmd
end,
filetypes = {'julia'};
filetypes = { "julia" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.fn.getcwd()
end;
};
end,
},
docs = {
package_json = "https://raw.githubusercontent.com/julia-vscode/julia-vscode/master/package.json";
package_json = "https://raw.githubusercontent.com/julia-vscode/julia-vscode/master/package.json",
description = [[
https://github.com/julia-vscode/julia-vscode
@ -80,8 +81,8 @@ julia -e 'print(Base.find_package("LanguageServer"))'
Note: the directory passed to `--project=...` should terminate with src, not LanguageServer.jl.
]];
};
]],
},
}
--- vim:et ts=2 sw=2

View File

@ -6,43 +6,41 @@
--- https://github.com/udalov/kotlin-vim (recommended)
--- Note that there is no LICENSE specified yet.
local util = require 'lspconfig/util'
local configs = require 'lspconfig/configs'
local util = require "lspconfig/util"
local configs = require "lspconfig/configs"
local bin_name = "kotlin-language-server"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..".bat"
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".bat"
end
--- The presence of one of these files indicates a project root directory
--
-- These are configuration files for the various build systems supported by
-- Kotlin. I am not sure whether the language server supports Ant projects,
-- but I'm keeping it here as well since Ant does support Kotlin.
local root_files = {
'settings.gradle', -- Gradle (multi-project)
'settings.gradle.kts', -- Gradle (multi-project)
'build.xml', -- Ant
'pom.xml', -- Maven
"settings.gradle", -- Gradle (multi-project)
"settings.gradle.kts", -- Gradle (multi-project)
"build.xml", -- Ant
"pom.xml", -- Maven
}
local fallback_root_files = {
'build.gradle', -- Gradle
'build.gradle.kts', -- Gradle
"build.gradle", -- Gradle
"build.gradle.kts", -- Gradle
}
configs.kotlin_language_server = {
default_config = {
filetypes = { "kotlin" };
filetypes = { "kotlin" },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or
util.root_pattern(unpack(fallback_root_files))(fname)
end;
cmd = { bin_name };
};
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
end,
cmd = { bin_name },
},
docs = {
package_json = "https://raw.githubusercontent.com/fwcd/vscode-kotlin/master/package.json";
package_json = "https://raw.githubusercontent.com/fwcd/vscode-kotlin/master/package.json",
description = [[
A kotlin language server which was developed for internal usage and
released afterwards. Maintaining is not done by the original author,
@ -51,10 +49,10 @@ configs.kotlin_language_server = {
It is builded via gradle and developed on github.
Source and additional description:
https://github.com/fwcd/kotlin-language-server
]];
]],
default_config = {
root_dir = [[root_pattern("settings.gradle")]];
cmd = {"kotlin-language-server"};
root_dir = [[root_pattern("settings.gradle")]],
cmd = { "kotlin-language-server" },
capabilities = [[
smart code completion,
diagnostics,
@ -72,9 +70,9 @@ configs.kotlin_language_server = {
Copyright (c) 2016 George Fraser
Copyright (c) 2018 fwcd
]];
};
};
]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,20 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.lean3ls = {
default_config = {
cmd = {"lean-language-server", "--stdio", "--", "-M", "4096", "-T", "100000" };
filetypes = {"lean3"};
cmd = { "lean-language-server", "--stdio", "--", "-M", "4096", "-T", "100000" },
filetypes = { "lean3" },
root_dir = function(fname)
return util.root_pattern("leanpkg.toml")(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end;
return util.root_pattern "leanpkg.toml"(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
on_new_config = function(config, root)
if not util.path.is_file(root .. "/leanpkg.toml") then return end
if not util.path.is_file(root .. "/leanpkg.toml") then
return
end
if not config.cmd_cwd then
config.cmd_cwd = root
end
end;
};
end,
},
docs = {
description = [[
https://github.com/leanprover/lean-client-js/tree/master/lean-language-server
@ -26,10 +28,10 @@ Once Lean is installed, you can install the Lean 3 language server by running
```sh
npm install -g lean-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]];
};
};
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,20 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.leanls = {
default_config = {
cmd = {"lean", "--server"};
filetypes = {"lean"};
cmd = { "lean", "--server" },
filetypes = { "lean" },
root_dir = function(fname)
return util.root_pattern("leanpkg.toml")(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end;
return util.root_pattern "leanpkg.toml"(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
on_new_config = function(config, root)
if not util.path.is_file(root .. "/leanpkg.toml") then return end
if not util.path.is_file(root .. "/leanpkg.toml") then
return
end
if not config.cmd_cwd then
config.cmd_cwd = root
end
end;
};
end,
},
docs = {
description = [[
https://github.com/leanprover/lean4
@ -24,10 +26,10 @@ Lean installation instructions can be found
The Lean 4 language server is built-in with a Lean 4 install
(and can be manually run with, e.g., `lean --server`).
]];
]],
default_config = {
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]];
};
};
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,13 +1,13 @@
local configs = require 'lspconfig/configs'
local lspui = require 'lspconfig/_lspui'
local configs = require "lspconfig/configs"
local lspui = require "lspconfig/_lspui"
return function ()
return function()
-- These options need to be cached before switching to the floating
-- buffer.
local buf_clients = vim.lsp.buf_get_clients()
local clients = vim.lsp.get_active_clients()
local buffer_filetype = vim.bo.filetype
local buffer_dir = vim.fn.expand('%:p:h')
local buffer_dir = vim.fn.expand "%:p:h"
local win_info = lspui.percentage_range_window(0.8, 0.7)
local bufnr, win_id = win_info.bufnr, win_info.win_id
@ -20,27 +20,30 @@ return function ()
end
local header = {
"Configured servers: "..table.concat(vim.tbl_keys(configs), ', '),
"Neovim logs at: "..(vim.lsp.get_log_path()),
"Configured servers: " .. table.concat(vim.tbl_keys(configs), ", "),
"Neovim logs at: " .. (vim.lsp.get_log_path()),
"",
tostring(#vim.tbl_keys(buf_clients)).." client(s) attached to this buffer: "..table.concat(buf_client_names, ', '),
tostring(#vim.tbl_keys(buf_clients)) .. " client(s) attached to this buffer: " .. table.concat(
buf_client_names,
", "
),
}
vim.list_extend(buf_lines, header)
local function trim_whitespace(cmd)
local trimmed_cmd = {}
for _, str in pairs(cmd) do
table.insert(trimmed_cmd, str:match'^%s*(.*)')
table.insert(trimmed_cmd, str:match "^%s*(.*)")
end
return trimmed_cmd
end
local function remove_newlines(cmd)
cmd = trim_whitespace(cmd)
cmd = table.concat(cmd, ' ')
cmd = vim.split(cmd, '\n')
cmd = table.concat(cmd, " ")
cmd = vim.split(cmd, "\n")
cmd = trim_whitespace(cmd)
cmd = table.concat(cmd, ' ')
cmd = table.concat(cmd, " ")
return cmd
end
@ -52,32 +55,32 @@ return function ()
end
return {
"",
indent.."Client: "..client.name.." (id "..tostring(client.id)..")",
indent.."\troot: "..client.workspaceFolders[1].name,
indent.."\tfiletypes: "..table.concat(client.config.filetypes or {}, ', '),
indent.."\tcmd: "..remove_newlines(client.config.cmd),
indent.."\t"..server_specific_info,
""
indent .. "Client: " .. client.name .. " (id " .. tostring(client.id) .. ")",
indent .. "\troot: " .. client.workspaceFolders[1].name,
indent .. "\tfiletypes: " .. table.concat(client.config.filetypes or {}, ", "),
indent .. "\tcmd: " .. remove_newlines(client.config.cmd),
indent .. "\t" .. server_specific_info,
"",
}
end
for _, client in pairs(buf_clients) do
local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
end
local active_section_header = {
"",
tostring(#clients).." active client(s): ",
tostring(#clients) .. " active client(s): ",
}
vim.list_extend(buf_lines, active_section_header)
for _, client in pairs(clients) do
local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
end
local matching_config_header = {
"",
"Clients that match the filetype "..buffer_filetype..":",
"Clients that match the filetype " .. buffer_filetype .. ":",
}
local cmd_not_found_msg = "False. Please check your path and ensure the server is installed"
vim.list_extend(buf_lines, matching_config_header)
@ -98,36 +101,36 @@ return function ()
for _, filetype_match in pairs(config.filetypes) do
if buffer_filetype == filetype_match then
local matching_config_info = {
indent.."",
indent.."Config: "..config.name,
indent.."\tcmd: "..cmd,
indent.."\tcmd is executable: ".. cmd_is_executable,
indent.."\tidentified root: "..(config.get_root_dir(buffer_dir) or "None"),
indent.."\tcustom handlers: "..table.concat(vim.tbl_keys(config.handlers), ", "),
indent .. "",
indent .. "Config: " .. config.name,
indent .. "\tcmd: " .. cmd,
indent .. "\tcmd is executable: " .. cmd_is_executable,
indent .. "\tidentified root: " .. (config.get_root_dir(buffer_dir) or "None"),
indent .. "\tcustom handlers: " .. table.concat(vim.tbl_keys(config.handlers), ", "),
}
vim.list_extend(buf_lines, matching_config_info)
vim.list_extend(buf_lines, matching_config_info)
end
end
else
local matching_config_info = {
"",
"Config: "..config.name,
"\tfiletype: ".."No filetypes defined, please define filetypes in setup().",
}
vim.list_extend(buf_lines, matching_config_info)
local matching_config_info = {
"",
"Config: " .. config.name,
"\tfiletype: " .. "No filetypes defined, please define filetypes in setup().",
}
vim.list_extend(buf_lines, matching_config_info)
end
end
buf_lines = vim.lsp.util._trim(buf_lines, {})
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, buf_lines )
vim.api.nvim_buf_set_option(bufnr,'modifiable',false)
vim.api.nvim_buf_set_option(bufnr,'filetype','lspinfo')
local configs_pattern = '\\%(' .. table.concat(vim.tbl_keys(configs), '\\|') .. '\\)'
vim.cmd('syntax match Title /\\%(Client\\|Config\\):.*\\zs' .. configs_pattern .. '/')
vim.cmd('syntax match Identifier /filetypes:.*\\zs\\<' .. buffer_filetype .. '\\>/')
vim.fn.matchadd("Error",
"No filetypes defined, please define filetypes in setup().\\|"..
"cmd not defined\\|" ..
cmd_not_found_msg)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<esc>', '<cmd>bd<CR>', { noremap = true})
vim.lsp.util.close_preview_autocmd({"BufHidden", "BufLeave"}, win_id)
end;
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, buf_lines)
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
vim.api.nvim_buf_set_option(bufnr, "filetype", "lspinfo")
local configs_pattern = "\\%(" .. table.concat(vim.tbl_keys(configs), "\\|") .. "\\)"
vim.cmd("syntax match Title /\\%(Client\\|Config\\):.*\\zs" .. configs_pattern .. "/")
vim.cmd("syntax match Identifier /filetypes:.*\\zs\\<" .. buffer_filetype .. "\\>/")
vim.fn.matchadd(
"Error",
"No filetypes defined, please define filetypes in setup().\\|" .. "cmd not defined\\|" .. cmd_not_found_msg
)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<esc>", "<cmd>bd<CR>", { noremap = true })
vim.lsp.util.close_preview_autocmd({ "BufHidden", "BufLeave" }, win_id)
end

View File

@ -1,24 +1,24 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "metals"
local bin_name = "metals"
configs[server_name] = {
default_config = {
cmd = {bin_name};
filetypes = {"scala"};
root_dir = util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml");
message_level = vim.lsp.protocol.MessageType.Log;
cmd = { bin_name },
filetypes = { "scala" },
root_dir = util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml"),
message_level = vim.lsp.protocol.MessageType.Log,
init_options = {
statusBarProvider = "show-message",
isHttpEnabled = true,
compilerOptions = {
snippetAutoIndent = false
}
};
};
statusBarProvider = "show-message",
isHttpEnabled = true,
compilerOptions = {
snippetAutoIndent = false,
},
},
},
docs = {
description = [[
description = [[
https://scalameta.org/metals/
Scala language server with rich IDE features.
@ -40,9 +40,9 @@ cs bootstrap \
-r sonatype:snapshots \
-o /usr/local/bin/metals -f
```
]];
]],
default_config = {
root_dir = [[util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml")]];
};
};
};
root_dir = [[util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml")]],
},
},
}

View File

@ -1,27 +1,25 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.nimls = {
default_config = {
cmd = {"nimlsp",};
filetypes = {'nim'};
cmd = { "nimlsp" },
filetypes = { "nim" },
root_dir = function(fname)
return util.root_pattern("*.nimble")(fname) or
util.find_git_ancestor(fname) or
util.path.dirname(fname)
end;
};
return util.root_pattern "*.nimble"(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
},
docs = {
package_json = "https://raw.githubusercontent.com/pragmagic/vscode-nim/master/package.json";
package_json = "https://raw.githubusercontent.com/pragmagic/vscode-nim/master/package.json",
description = [[
https://github.com/PMunch/nimlsp
`nimlsp` can be installed via the `nimble` package manager:
```sh
nimble install nimlsp
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git") or os_homedir]];
};
};
root_dir = [[root_pattern(".git") or os_homedir]],
},
},
}

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "ocamlls"
local bin_name = "ocaml-language-server"
configs[server_name] = {
default_config = {
cmd = { bin_name, "--stdio" };
filetypes = { "ocaml", "reason" };
root_dir = util.root_pattern("*.opam", "esy.json", "package.json");
};
cmd = { bin_name, "--stdio" },
filetypes = { "ocaml", "reason" },
root_dir = util.root_pattern("*.opam", "esy.json", "package.json"),
},
docs = {
description = [[
https://github.com/ocaml-lsp/ocaml-language-server
@ -18,10 +18,10 @@ https://github.com/ocaml-lsp/ocaml-language-server
```sh
npm install -g ocaml-langauge-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("*.opam", "esy.json", "package.json")]];
};
};
};
root_dir = [[root_pattern("*.opam", "esy.json", "package.json")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local language_id_of = {
menhir = 'ocaml.menhir';
ocaml = 'ocaml';
ocamlinterface = 'ocaml.interface';
ocamllex = 'ocaml.ocamllex';
reason = 'reason';
menhir = "ocaml.menhir",
ocaml = "ocaml",
ocamlinterface = "ocaml.interface",
ocamllex = "ocaml.ocamllex",
reason = "reason",
}
local filetypes = {}
@ -15,15 +15,17 @@ for ftype, _ in pairs(language_id_of) do
table.insert(filetypes, ftype)
end
local get_language_id = function (_, ftype) return language_id_of[ftype] end
local get_language_id = function(_, ftype)
return language_id_of[ftype]
end
configs.ocamllsp = {
default_config = {
cmd = {"ocamllsp",};
filetypes = filetypes;
root_dir = util.root_pattern("*.opam", "esy.json", "package.json", ".git");
get_language_id = get_language_id;
};
cmd = { "ocamllsp" },
filetypes = filetypes,
root_dir = util.root_pattern("*.opam", "esy.json", "package.json", ".git"),
get_language_id = get_language_id,
},
docs = {
description = [[
https://github.com/ocaml/ocaml-lsp
@ -35,9 +37,9 @@ To install the lsp server in a particular opam switch:
opam pin add ocaml-lsp-server https://github.com/ocaml/ocaml-lsp.git
opam install ocaml-lsp-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("*.opam", "esy.json", "package.json", ".git")]];
};
};
root_dir = [[root_pattern("*.opam", "esy.json", "package.json", ".git")]],
},
},
}

View File

@ -1,14 +1,13 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local server_name = 'omnisharp'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "omnisharp"
configs[server_name] = {
default_config = {
filetypes = {"cs", "vb"};
root_dir = util.root_pattern("*.csproj", "*.sln");
init_options = {
};
};
filetypes = { "cs", "vb" },
root_dir = util.root_pattern("*.csproj", "*.sln"),
init_options = {},
},
-- on_new_config = function(new_config) end;
-- on_attach = function(client, bufnr) end;
docs = {
@ -39,11 +38,11 @@ Note, if you download the executable for darwin you will need to strip the quara
```bash
find /path/to/omnisharp-osx | xargs xattr -r -d com.apple.quarantine
```
]];
]],
default_config = {
root_dir = [[root_pattern(".csproj", ".sln")]];
};
};
root_dir = [[root_pattern(".csproj", ".sln")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,37 +1,43 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.perlls = {
default_config = {
cmd = {"perl",
"-MPerl::LanguageServer",
"-e", "Perl::LanguageServer::run","--",
"--port 13603", "--nostdio 0", "--version 2.1.0"};
cmd = {
"perl",
"-MPerl::LanguageServer",
"-e",
"Perl::LanguageServer::run",
"--",
"--port 13603",
"--nostdio 0",
"--version 2.1.0",
},
settings = {
perl = {
perlCmd = 'perl';
perlInc = ' ';
fileFilter = {".pm",".pl"};
ignoreDirs = '.git';
};
};
filetypes = {"perl"};
perlCmd = "perl",
perlInc = " ",
fileFilter = { ".pm", ".pl" },
ignoreDirs = ".git",
},
},
filetypes = { "perl" },
root_dir = function(fname)
return util.root_pattern(".git")(fname) or vim.fn.getcwd()
end;
};
return util.root_pattern ".git"(fname) or vim.fn.getcwd()
end,
},
docs = {
package_json = "https://raw.githubusercontent.com/richterger/Perl-LanguageServer/master/clients/vscode/perl/package.json";
package_json = "https://raw.githubusercontent.com/richterger/Perl-LanguageServer/master/clients/vscode/perl/package.json",
description = [[
https://github.com/richterger/Perl-LanguageServer/tree/master/clients/vscode/perl
`Perl-LanguageServer`, a language server for Perl.
To use the language server, ensure that you have Perl::LanguageServer installed and perl command is on your path.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,32 +1,32 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "phpactor"
local bin_name = "phpactor"
configs[server_name] = {
default_config = {
cmd = {bin_name, "language-server"};
filetypes = {"php"};
root_dir = function (pattern)
local cwd = vim.loop.cwd();
local root = util.root_pattern("composer.json", ".git")(pattern);
cmd = { bin_name, "language-server" },
filetypes = { "php" },
root_dir = function(pattern)
local cwd = vim.loop.cwd()
local root = util.root_pattern("composer.json", ".git")(pattern)
-- prefer cwd if root is a descendant
return util.path.is_descendant(cwd, root) and cwd or root;
end;
};
return util.path.is_descendant(cwd, root) and cwd or root
end,
},
docs = {
description = [[
https://github.com/phpactor/phpactor
Installation: https://phpactor.readthedocs.io/en/master/usage/standalone.html#global-installation
]];
]],
default_config = {
cmd = {"phpactor", "language-server"};
root_dir = [[root_pattern("composer.json", ".git")]];
};
};
cmd = { "phpactor", "language-server" },
root_dir = [[root_pattern("composer.json", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,14 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "powershell_es"
local temp_path = vim.fn.stdpath('cache')
local temp_path = vim.fn.stdpath "cache"
local function make_cmd(bundle_path)
if bundle_path ~= nil then
local command_fmt = [[%s/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath %s -LogPath %s/powershell_es.log -SessionDetailsPath %s/powershell_es.session.json -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Normal]]
local command_fmt =
[[%s/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath %s -LogPath %s/powershell_es.log -SessionDetailsPath %s/powershell_es.session.json -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Normal]]
local command = command_fmt:format(bundle_path, bundle_path, temp_path, temp_path)
return {"pwsh", "-NoLogo", "-NoProfile", "-Command", command}
return { "pwsh", "-NoLogo", "-NoProfile", "-Command", command }
end
end
@ -18,11 +19,11 @@ configs[server_name] = {
local bundle_path = new_config.bundle_path
new_config.cmd = make_cmd(bundle_path)
end,
filetypes = {"ps1"},
filetypes = { "ps1" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.fn.getcwd()
end;
};
end,
},
docs = {
description = [[
https://github.com/PowerShell/PowerShellEditorServices
@ -51,11 +52,11 @@ require'lspconfig'.powershell_es.setup{
cmd = {'pwsh', '-NoLogo', '-NoProfile', '-Command', "c:/PSES/Start-EditorServices.ps1 ..."}
}
```
]];
]],
default_config = {
root_dir = "git root or current directory";
};
};
};
root_dir = "git root or current directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,31 +1,31 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "prismals"
local bin_name = "prisma-language-server"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..".cmd"
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".cmd"
end
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"prisma"};
cmd = { bin_name, "--stdio" },
filetypes = { "prisma" },
settings = {
prisma = {
prismaFmtBinPath = "";
}
};
root_dir =util.root_pattern(".git", "package.json");
};
prismaFmtBinPath = "",
},
},
root_dir = util.root_pattern(".git", "package.json"),
},
docs = {
description = [[
npm install -g @prisma/language-server
'prismals, a language server for the prisma javascript and typescript orm'
]];
]],
default_config = {
root_dir = [[root_pattern(".git", "package.json")]];
};
};
root_dir = [[root_pattern(".git", "package.json")]],
},
},
}

View File

@ -1,30 +1,30 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "purescriptls"
local bin_name = "purescript-language-server"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..'.cmd'
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".cmd"
end
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"purescript"};
root_dir = util.root_pattern("spago.dhall", "bower.json");
};
cmd = { bin_name, "--stdio" },
filetypes = { "purescript" },
root_dir = util.root_pattern("spago.dhall", "bower.json"),
},
docs = {
package_json = "https://raw.githubusercontent.com/nwolverson/vscode-ide-purescript/master/package.json";
package_json = "https://raw.githubusercontent.com/nwolverson/vscode-ide-purescript/master/package.json",
description = [[
https://github.com/nwolverson/purescript-language-server
`purescript-language-server` can be installed via `npm`
```sh
npm install -g purescript-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("spago.dhall, bower.json")]];
};
};
};
root_dir = [[root_pattern("spago.dhall, bower.json")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local configs = require "lspconfig/configs"
configs.pyls = {
default_config = {
cmd = {"pyls"};
filetypes = {"python"};
cmd = { "pyls" },
filetypes = { "python" },
root_dir = function(fname)
return vim.fn.getcwd()
end;
};
end,
},
docs = {
package_json = "https://raw.githubusercontent.com/palantir/python-language-server/develop/vscode-client/package.json";
package_json = "https://raw.githubusercontent.com/palantir/python-language-server/develop/vscode-client/package.json",
description = [[
https://github.com/palantir/python-language-server
@ -17,10 +17,10 @@ https://github.com/palantir/python-language-server
The language server can be installed via `pipx install 'python-language-server[all]'`.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,37 +1,36 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local name = "pyls_ms"
configs[name] = {
default_config = {
filetypes = {"python"};
filetypes = { "python" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.loop.os_homedir()
end;
end,
settings = {
python = {
analysis = {
errors = {};
info = {};
disabled = {};
};
};
};
errors = {},
info = {},
disabled = {},
},
},
},
init_options = {
interpreter = {
properties =
{
InterpreterPath = "";
Version = "";
};
};
displayOptions = {};
analysisUpdates = true;
asyncStartup = true;
};
};
properties = {
InterpreterPath = "",
Version = "",
},
},
displayOptions = {},
analysisUpdates = true,
asyncStartup = true,
},
},
docs = {
description = [[
https://github.com/Microsoft/python-language-server
@ -61,11 +60,11 @@ Version = "3.8"
This server accepts configuration via the `settings` key.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,23 +1,21 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.pylsp = {
default_config = {
cmd = {"pylsp"};
filetypes = {"python"};
cmd = { "pylsp" },
filetypes = { "python" },
root_dir = function(fname)
local root_files = {
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile"
"Pipfile",
}
return util.root_pattern(unpack(root_files))(fname) or
util.find_git_ancestor(fname) or
util.path.dirname(fname)
end;
};
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
},
docs = {
description = [[
https://github.com/python-lsp/python-lsp-server
@ -28,7 +26,7 @@ The language server can be installed via `pipx install 'python-lsp-server[all]'`
Further instructions can be found in the [project's README](https://github.com/python-lsp/python-lsp-server).
Note: This is a community fork of `pyls`.
]];
};
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,23 +1,23 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "pyright"
local bin_name = "pyright-langserver"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..".cmd"
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".cmd"
end
local root_files = {
'setup.py',
'pyproject.toml',
'setup.cfg',
'requirements.txt',
'.git',
"setup.py",
"pyproject.toml",
"setup.cfg",
"requirements.txt",
".git",
}
local function organize_imports()
local params = {
command = 'pyright.organizeimports',
command = "pyright.organizeimports",
arguments = { vim.uri_from_bufnr(0) },
}
vim.lsp.buf.execute_command(params)
@ -25,36 +25,35 @@ end
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"python"};
cmd = { bin_name, "--stdio" },
filetypes = { "python" },
root_dir = function(filename)
return util.root_pattern(unpack(root_files))(filename) or
util.path.dirname(filename)
end;
return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename)
end,
settings = {
python = {
analysis = {
autoSearchPaths = true;
useLibraryCodeForTypes = true;
diagnosticMode = 'workspace';
};
};
};
};
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "workspace",
},
},
},
},
commands = {
PyrightOrganizeImports = {
organize_imports;
description = "Organize Imports";
};
};
organize_imports,
description = "Organize Imports",
},
},
docs = {
package_json = 'https://raw.githubusercontent.com/microsoft/pyright/master/packages/vscode-pyright/package.json',
package_json = "https://raw.githubusercontent.com/microsoft/pyright/master/packages/vscode-pyright/package.json",
description = [[
https://github.com/microsoft/pyright
`pyright`, a static type checker and language server for python
]];
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,17 +1,17 @@
local util = require 'lspconfig/util'
local configs = require 'lspconfig/configs'
local util = require "lspconfig/util"
local configs = require "lspconfig/configs"
configs.r_language_server = {
default_config = {
cmd = {"R", "--slave", "-e", "languageserver::run()"};
filetypes = {"r", "rmd"};
cmd = { "R", "--slave", "-e", "languageserver::run()" },
filetypes = { "r", "rmd" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.loop.os_homedir()
end;
log_level = vim.lsp.protocol.MessageType.Warning;
};
end,
log_level = vim.lsp.protocol.MessageType.Warning,
},
docs = {
package_json = "https://raw.githubusercontent.com/REditorSupport/vscode-r-lsp/master/package.json";
package_json = "https://raw.githubusercontent.com/REditorSupport/vscode-r-lsp/master/package.json",
description = [[
[languageserver](https://github.com/REditorSupport/languageserver) is an
implementation of the Microsoft's Language Server Protocol for the R
@ -22,9 +22,9 @@ configs.r_language_server = {
```R
install.packages("languageserver")
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git") or os_homedir]]
};
};
root_dir = [[root_pattern(".git") or os_homedir]],
},
},
}

View File

@ -1,21 +1,20 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local root_files = {
'.git',
".git",
}
configs.racket_langserver = {
default_config = {
cmd = {"racket", "--lib", "racket-langserver"};
filetypes = {"racket", "scheme"};
cmd = { "racket", "--lib", "racket-langserver" },
filetypes = { "racket", "scheme" },
root_dir = function(filename)
return util.root_pattern(unpack(root_files))(filename) or
util.path.dirname(filename)
end
};
return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename)
end,
},
docs = {
description = [[
description = [[
[https://github.com/jeapostrophe/racket-langserver](https://github.com/jeapostrophe/racket-langserver)
The Racket language server. This project seeks to use
@ -23,6 +22,6 @@ The Racket language server. This project seeks to use
functionality that mimics DrRacket's code tools as closely as possible.
Install via `raco`: `raco pkg install racket-langserver`
]];
};
};
]],
},
}

View File

@ -1,14 +1,14 @@
local lspconfig = require('lspconfig')
local configs = require('lspconfig/configs')
local lspconfig = require "lspconfig"
local configs = require "lspconfig/configs"
local name = 'rescriptls'
local name = "rescriptls"
configs[name] = {
default_config = {
cmd = {},
filetypes = {'rescript'},
root_dir = lspconfig.util.root_pattern('bsconfig.json', '.git'),
settings = {}
filetypes = { "rescript" },
root_dir = lspconfig.util.root_pattern("bsconfig.json", ".git"),
settings = {},
},
docs = {
description = [[
@ -40,6 +40,6 @@ cmd = {
Another option is to use vscode extension [release](https://github.com/rescript-lang/rescript-vscode/releases).
Take a look at [here](https://github.com/rescript-lang/rescript-vscode#use-with-other-editors) for instructions.
]]
}
]],
},
}

View File

@ -1,12 +1,12 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.rls = {
default_config = {
cmd = {"rls"};
filetypes = {"rust"};
root_dir = util.root_pattern("Cargo.toml");
};
cmd = { "rls" },
filetypes = { "rust" },
root_dir = util.root_pattern "Cargo.toml",
},
docs = {
description = [[
https://github.com/rust-lang/rls
@ -35,10 +35,10 @@ If you want to use rls for a particular build, eg nightly, set cmd as follows:
```lua
cmd = {"rustup", "run", "nightly", "rls"}
```
]];
]],
default_config = {
root_dir = [[root_pattern("Cargo.toml")]];
};
};
};
root_dir = [[root_pattern("Cargo.toml")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,21 +1,19 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local name = "rnix"
configs[name] = {
default_config = {
cmd = {"rnix-lsp"};
filetypes = {"nix"};
cmd = { "rnix-lsp" },
filetypes = { "nix" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.loop.os_homedir()
end;
settings = {
};
init_options = {
};
};
end,
settings = {},
init_options = {},
},
docs = {
description = [[
https://github.com/nix-community/rnix-lsp
@ -26,9 +24,9 @@ To install manually, run `cargo install rnix-lsp`. If you are using nix, rnix-ls
This server accepts configuration via the `settings` key.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
};
root_dir = "vim's starting directory",
},
},
}

View File

@ -1,26 +1,25 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.rome = {
default_config = {
cmd = {'rome', 'lsp'},
cmd = { "rome", "lsp" },
filetypes = {
'javascript',
'javascriptreact',
'json',
'typescript',
'typescript.tsx',
'typescriptreact'
"javascript",
"javascriptreact",
"json",
"typescript",
"typescript.tsx",
"typescriptreact",
},
root_dir = function(fname)
return util.find_package_json_ancestor(fname) or
util.find_node_modules_ancestor(fname) or
util.find_git_ancestor(fname) or
util.path.dirname(fname)
end
return util.find_package_json_ancestor(fname) or util.find_node_modules_ancestor(fname) or util.find_git_ancestor(
fname
) or util.path.dirname(fname)
end,
},
docs = {
description = [[
description = [[
https://rome.tools
Language server for the Rome Frontend Toolchain.
@ -29,9 +28,8 @@ Language server for the Rome Frontend Toolchain.
npm install [-g] rome
```
]],
default_config = {
root_dir = [[root_pattern('package.json', 'node_modules', '.git') or dirname]]
}
}
default_config = {
root_dir = [[root_pattern('package.json', 'node_modules', '.git') or dirname]],
},
},
}

View File

@ -1,22 +1,23 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local lsp = vim.lsp
local function reload_workspace(bufnr)
bufnr = util.validate_bufnr(bufnr)
lsp.buf_request(bufnr, 'rust-analyzer/reloadWorkspace', nil,
function(err, _, result, _)
if err then error(tostring(err)) end
vim.notify("Cargo workspace reloaded")
end)
lsp.buf_request(bufnr, "rust-analyzer/reloadWorkspace", nil, function(err, _, result, _)
if err then
error(tostring(err))
end
vim.notify "Cargo workspace reloaded"
end)
end
configs.rust_analyzer = {
default_config = {
cmd = {"rust-analyzer"};
filetypes = {"rust"};
cmd = { "rust-analyzer" },
filetypes = { "rust" },
root_dir = function(fname)
local cargo_crate_dir = util.root_pattern("Cargo.toml")(fname)
local cargo_crate_dir = util.root_pattern "Cargo.toml"(fname)
local cmd = "cargo metadata --no-deps --format-version 1"
if cargo_crate_dir ~= nil then
cmd = cmd .. " --manifest-path " .. util.path.join(cargo_crate_dir, "Cargo.toml")
@ -26,37 +27,37 @@ configs.rust_analyzer = {
if vim.v.shell_error == 0 then
cargo_workspace_dir = vim.fn.json_decode(cargo_metadata)["workspace_root"]
end
return cargo_workspace_dir or
cargo_crate_dir or
util.root_pattern("rust-project.json")(fname) or
util.find_git_ancestor(fname)
end;
return cargo_workspace_dir
or cargo_crate_dir
or util.root_pattern "rust-project.json"(fname)
or util.find_git_ancestor(fname)
end,
settings = {
["rust-analyzer"] = {}
};
};
["rust-analyzer"] = {},
},
},
commands = {
CargoReload = {
function()
reload_workspace(0)
end;
description = "Reload current cargo workspace"
}
};
end,
description = "Reload current cargo workspace",
},
},
docs = {
package_json = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/master/editors/code/package.json";
package_json = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/master/editors/code/package.json",
description = [[
https://github.com/rust-analyzer/rust-analyzer
rust-analyzer (aka rls 2.0), a language server for Rust
See [docs](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#settings) for extra settings.
]];
]],
default_config = {
root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]];
};
};
};
root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]],
},
},
}
configs.rust_analyzer.reload_workspace = reload_workspace
-- vim:et ts=2 sw=2

View File

@ -1,24 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.scry = {
default_config = {
cmd = {'scry'},
filetypes = {'crystal'},
cmd = { "scry" },
filetypes = { "crystal" },
root_dir = function(fname)
return util.root_pattern('shard.yml')(fname) or
util.find_git_ancestor(fname) or
util.path.dirname(fname)
end
return util.root_pattern "shard.yml"(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
end,
},
docs = {
description = [[
description = [[
https://github.com/crystal-lang-tools/scry
Crystal language server.
]],
default_config = {
root_dir = [[root_pattern('shard.yml', '.git') or dirname]]
}
}
default_config = {
root_dir = [[root_pattern('shard.yml', '.git') or dirname]],
},
},
}

View File

@ -1,23 +1,23 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local bin_name = "solargraph"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..'.bat'
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".bat"
end
configs.solargraph = {
default_config = {
cmd = {bin_name, "stdio"};
cmd = { bin_name, "stdio" },
settings = {
solargraph = {
diagnostics = true;
};
};
filetypes = {"ruby"};
root_dir = util.root_pattern("Gemfile", ".git");
};
diagnostics = true,
},
},
filetypes = { "ruby" },
root_dir = util.root_pattern("Gemfile", ".git"),
},
docs = {
package_json = "https://raw.githubusercontent.com/castwide/vscode-solargraph/master/package.json";
package_json = "https://raw.githubusercontent.com/castwide/vscode-solargraph/master/package.json",
description = [[
https://solargraph.org/
@ -28,10 +28,10 @@ You can install solargraph via gem install.
```sh
gem install --user-install solargraph
```
]];
]],
default_config = {
root_dir = [[root_pattern("Gemfile", ".git")]];
};
};
};
root_dir = [[root_pattern("Gemfile", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "sorbet"
local bin_name = "srb"
configs[server_name] = {
default_config = {
cmd = {bin_name, "tc", "--lsp"};
filetypes = {"ruby"};
root_dir = util.root_pattern("Gemfile", ".git");
};
cmd = { bin_name, "tc", "--lsp" },
filetypes = { "ruby" },
root_dir = util.root_pattern("Gemfile", ".git"),
},
docs = {
description = [[
https://sorbet.org
@ -22,9 +22,9 @@ Sorbet up for new projects: https://sorbet.org/docs/adopting.
```sh
gem install sorbet
```
]];
]],
default_config = {
root_dir = [[root_pattern("Gemfile", ".git")]];
};
};
};
root_dir = [[root_pattern("Gemfile", ".git")]],
},
},
}

View File

@ -1,22 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.sourcekit = {
default_config = {
cmd = {"xcrun", "sourcekit-lsp"};
filetypes = {"swift", "c", "cpp", "objective-c", "objective-cpp"};
root_dir = util.root_pattern("Package.swift", ".git")
};
cmd = { "xcrun", "sourcekit-lsp" },
filetypes = { "swift", "c", "cpp", "objective-c", "objective-cpp" },
root_dir = util.root_pattern("Package.swift", ".git"),
},
docs = {
package_json = "https://raw.githubusercontent.com/apple/sourcekit-lsp/main/Editors/vscode/package.json";
package_json = "https://raw.githubusercontent.com/apple/sourcekit-lsp/main/Editors/vscode/package.json",
description = [[
https://github.com/apple/sourcekit-lsp
Language server for Swift and C/C++/Objective-C.
]];
]],
default_config = {
root_dir = [[root_pattern("Package.swift", ".git")]];
};
};
};
root_dir = [[root_pattern("Package.swift", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,18 +1,18 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "sqlls"
local root_pattern = util.root_pattern(".sqllsrc.json")
local root_pattern = util.root_pattern ".sqllsrc.json"
configs[server_name] = {
default_config = {
filetypes = {"sql", "mysql"};
filetypes = { "sql", "mysql" },
root_dir = function(fname)
return root_pattern(fname) or vim.loop.os_homedir()
end;
settings = {};
};
end,
settings = {},
},
docs = {
description = [[
https://github.com/joe-re/sql-language-server
@ -28,8 +28,8 @@ require'lspconfig'.sqlls.setup{
This LSP can be installed via `npm`. Find further instructions on manual installation of the sql-language-server at [joe-re/sql-language-server](https://github.com/joe-re/sql-language-server).
<br>
]];
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.sqls = {
default_config = {
cmd = {"sqls"};
filetypes = {"sql", "mysql"};
cmd = { "sqls" },
filetypes = { "sql", "mysql" },
root_dir = function(fname)
return util.root_pattern("config.yml")(fname) or util.path.dirname(fname)
end;
settings = {};
};
return util.root_pattern "config.yml"(fname) or util.path.dirname(fname)
end,
settings = {},
},
docs = {
description = [[
https://github.com/lighttiger2505/sqls
@ -22,8 +22,8 @@ require'lspconfig'.sqls.setup{
```
Sqls can be installed via `go get github.com/lighttiger2505/sqls`. Instructions for compiling Sqls from the source can be found at [lighttiger2505/sqls](https://github.com/lighttiger2505/sqls).
]];
};
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,26 +1,26 @@
local configs = require('lspconfig/configs')
local util = require('lspconfig/util')
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.stylelint_lsp = {
default_config = {
cmd = {'stylelint-lsp', '--stdio'},
cmd = { "stylelint-lsp", "--stdio" },
filetypes = {
'css',
'less',
'scss',
'sugarss',
'vue',
'wxss',
'javascript',
'javascriptreact',
'typescript',
'typescriptreact'
};
root_dir = util.root_pattern('.stylelintrc', 'package.json');
settings = {};
"css",
"less",
"scss",
"sugarss",
"vue",
"wxss",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
root_dir = util.root_pattern(".stylelintrc", "package.json"),
settings = {},
},
docs = {
package_json = "https://raw.githubusercontent.com/bmatcuk/coc-stylelintplus/master/package.json";
package_json = "https://raw.githubusercontent.com/bmatcuk/coc-stylelintplus/master/package.json",
description = [[
https://github.com/bmatcuk/stylelint-lsp
@ -41,9 +41,9 @@ require'lspconfig'.stylelint_lsp.setup{
}
}
```
]];
]],
default_config = {
root_dir = [[ root_pattern('.stylelintrc', 'package.json') ]];
};
};
root_dir = [[ root_pattern('.stylelintrc', 'package.json') ]],
},
},
}

View File

@ -1,19 +1,19 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local name = "sumneko_lua"
configs[name] = {
default_config = {
filetypes = {'lua'};
filetypes = { "lua" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or util.path.dirname(fname)
end;
log_level = vim.lsp.protocol.MessageType.Warning;
settings = { Lua = { telemetry = { enable = false }}};
};
end,
log_level = vim.lsp.protocol.MessageType.Warning,
settings = { Lua = { telemetry = { enable = false } } },
},
docs = {
package_json = "https://raw.githubusercontent.com/sumneko/vscode-lua/master/package.json";
package_json = "https://raw.githubusercontent.com/sumneko/vscode-lua/master/package.json",
description = [[
https://github.com/sumneko/lua-language-server
@ -69,10 +69,10 @@ require'lspconfig'.sumneko_lua.setup {
},
}
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git") or bufdir]];
};
};
root_dir = [[root_pattern(".git") or bufdir]],
},
},
}
-- vim:et ts=2

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = 'svelte'
local bin_name = 'svelteserver'
local server_name = "svelte"
local bin_name = "svelteserver"
configs[server_name] = {
default_config = {
cmd = {bin_name, '--stdio'};
filetypes = {'svelte'};
root_dir = util.root_pattern("package.json", ".git");
};
cmd = { bin_name, "--stdio" },
filetypes = { "svelte" },
root_dir = util.root_pattern("package.json", ".git"),
},
docs = {
description = [[
https://github.com/sveltejs/language-tools/tree/master/packages/language-server
@ -18,11 +18,11 @@ https://github.com/sveltejs/language-tools/tree/master/packages/language-server
```sh
npm install -g svelte-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("package.json", ".git")]];
};
}
root_dir = [[root_pattern("package.json", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,5 +1,5 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "svls"
@ -7,13 +7,13 @@ configs[server_name] = {
default_config = {
cmd = { "svls" },
filetypes = { "verilog", "systemverilog" },
root_dir = util.root_pattern(".git");
};
root_dir = util.root_pattern ".git",
},
docs = {
description = [[
https://github.com/dalance/svls
Language server for verilog and SystemVerilog
]];
}
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,68 +1,68 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = 'tailwindcss'
local bin_name = 'tailwindcss-language-server'
local server_name = "tailwindcss"
local bin_name = "tailwindcss-language-server"
configs[server_name] = {
default_config = {
cmd = {bin_name, '--stdio'},
cmd = { bin_name, "--stdio" },
-- filetypes copied and adjusted from tailwindcss-intellisense
filetypes = {
-- html
'aspnetcorerazor',
'astro',
'astro-markdown',
'blade',
'django-html',
'edge',
'eelixir', -- vim ft
'ejs',
'erb',
'eruby', -- vim ft
'gohtml',
'haml',
'handlebars',
'hbs',
'html',
"aspnetcorerazor",
"astro",
"astro-markdown",
"blade",
"django-html",
"edge",
"eelixir", -- vim ft
"ejs",
"erb",
"eruby", -- vim ft
"gohtml",
"haml",
"handlebars",
"hbs",
"html",
-- 'HTML (Eex)',
-- 'HTML (EEx)',
'html-eex',
'jade',
'leaf',
'liquid',
'markdown',
'mdx',
'mustache',
'njk',
'nunjucks',
'php',
'razor',
'slim',
'twig',
"html-eex",
"jade",
"leaf",
"liquid",
"markdown",
"mdx",
"mustache",
"njk",
"nunjucks",
"php",
"razor",
"slim",
"twig",
-- css
'css',
'less',
'postcss',
'sass',
'scss',
'stylus',
'sugarss',
"css",
"less",
"postcss",
"sass",
"scss",
"stylus",
"sugarss",
-- js
'javascript',
'javascriptreact',
'reason',
'rescript',
'typescript',
'typescriptreact',
"javascript",
"javascriptreact",
"reason",
"rescript",
"typescript",
"typescriptreact",
-- mixed
'vue',
'svelte',
"vue",
"svelte",
},
init_options = {
userLanguages = {
eelixir = 'html-eex',
eruby = 'erb',
eelixir = "html-eex",
eruby = "erb",
},
},
settings = {
@ -80,19 +80,24 @@ configs[server_name] = {
},
},
on_new_config = function(new_config)
if not new_config.settings then new_config.settings = {} end
if not new_config.settings.editor then new_config.settings.editor = {} end
if not new_config.settings then
new_config.settings = {}
end
if not new_config.settings.editor then
new_config.settings.editor = {}
end
if not new_config.settings.editor.tabSize then
-- set tab size for hover
new_config.settings.editor.tabSize = vim.lsp.util.get_effective_tabstop()
end
end,
root_dir = function(fname)
return util.root_pattern('tailwind.config.js', 'tailwind.config.ts')(fname) or
util.root_pattern('postcss.config.js', 'postcss.config.ts')(fname) or
util.find_package_json_ancestor(fname) or
util.find_node_modules_ancestor(fname) or
util.find_git_ancestor(fname)
return util.root_pattern("tailwind.config.js", "tailwind.config.ts")(fname) or util.root_pattern(
"postcss.config.js",
"postcss.config.ts"
)(fname) or util.find_package_json_ancestor(fname) or util.find_node_modules_ancestor(fname) or util.find_git_ancestor(
fname
)
end,
},
docs = {

View File

@ -1,23 +1,23 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.terraformls = {
default_config = {
cmd = {"terraform-ls", "serve"};
filetypes = {"terraform"};
root_dir = util.root_pattern(".terraform", ".git");
};
cmd = { "terraform-ls", "serve" },
filetypes = { "terraform" },
root_dir = util.root_pattern(".terraform", ".git"),
},
docs = {
package_json = "https://raw.githubusercontent.com/hashicorp/vscode-terraform/master/package.json";
package_json = "https://raw.githubusercontent.com/hashicorp/vscode-terraform/master/package.json",
description = [[
https://github.com/hashicorp/terraform-ls
Terraform language server
Download a released binary from https://github.com/hashicorp/terraform-ls/releases.
]];
]],
default_config = {
root_dir = [[root_pattern(".terraform", ".git")]];
};
};
root_dir = [[root_pattern(".terraform", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,39 +1,44 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local lsp = vim.lsp
local texlab_build_status = vim.tbl_add_reverse_lookup {
Success = 0;
Error = 1;
Failure = 2;
Cancelled = 3;
Success = 0,
Error = 1,
Failure = 2,
Cancelled = 3,
}
local texlab_forward_status = vim.tbl_add_reverse_lookup {
Success = 0;
Error = 1;
Failure = 2;
Unconfigured = 3;
Success = 0,
Error = 1,
Failure = 2,
Unconfigured = 3,
}
local function buf_build(bufnr)
bufnr = util.validate_bufnr(bufnr)
local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) } }
lsp.buf_request(bufnr, 'textDocument/build', params,
function(err, _, result, _)
if err then error(tostring(err)) end
print("Build "..texlab_build_status[result.status])
end)
local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) } }
lsp.buf_request(bufnr, "textDocument/build", params, function(err, _, result, _)
if err then
error(tostring(err))
end
print("Build " .. texlab_build_status[result.status])
end)
end
local function buf_search(bufnr)
bufnr = util.validate_bufnr(bufnr)
local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) }, position = { line = vim.fn.line('.')-1, character = vim.fn.col('.') }}
lsp.buf_request(bufnr, 'textDocument/forwardSearch', params,
function(err, _, result, _)
if err then error(tostring(err)) end
print("Search "..texlab_forward_status[result.status])
end)
local params = {
textDocument = { uri = vim.uri_from_bufnr(bufnr) },
position = { line = vim.fn.line "." - 1, character = vim.fn.col "." },
}
lsp.buf_request(bufnr, "textDocument/forwardSearch", params, function(err, _, result, _)
if err then
error(tostring(err))
end
print("Search " .. texlab_forward_status[result.status])
end)
end
-- bufnr isn't actually required here, but we need a valid buffer in order to
@ -50,54 +55,54 @@ end
configs.texlab = {
default_config = {
cmd = {"texlab"};
filetypes = {"tex", "bib"};
cmd = { "texlab" },
filetypes = { "tex", "bib" },
root_dir = function(filename)
return util.path.dirname(filename)
end;
end,
settings = {
texlab = {
rootDirectory = nil;
rootDirectory = nil,
build = {
executable = "latexmk";
args = {"-pdf", "-interaction=nonstopmode", "-synctex=1", "%f"};
onSave = false;
forwardSearchAfter = false;
};
auxDirectory = '.';
executable = "latexmk",
args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
onSave = false,
forwardSearchAfter = false,
},
auxDirectory = ".",
forwardSearch = {
executable = nil;
args = {};
};
executable = nil,
args = {},
},
chktex = {
onOpenAndSave = false;
onEdit = false;
};
diagnosticsDelay = 300;
latexFormatter = 'latexindent';
onOpenAndSave = false,
onEdit = false,
},
diagnosticsDelay = 300,
latexFormatter = "latexindent",
latexindent = {
["local"] = nil; -- local is a reserved keyword
modifyLineBreaks = false;
};
bibtexFormatter = 'texlab';
formatterLineLength = 80;
};
};
};
["local"] = nil, -- local is a reserved keyword
modifyLineBreaks = false,
},
bibtexFormatter = "texlab",
formatterLineLength = 80,
},
},
},
commands = {
TexlabBuild = {
function()
buf_build(0)
end;
description = "Build the current buffer";
};
end,
description = "Build the current buffer",
},
TexlabForward = {
function()
buf_search(0)
end;
description = "Forward search from current position";
}
};
buf_search(0)
end,
description = "Forward search from current position",
},
},
docs = {
description = [[
https://github.com/latex-lsp/texlab
@ -105,11 +110,11 @@ https://github.com/latex-lsp/texlab
A completion engine built from scratch for (La)TeX.
See https://github.com/latex-lsp/texlab/blob/master/docs/options.md for configuration options.
]];
]],
default_config = {
root_dir = "vim's starting directory";
};
};
root_dir = "vim's starting directory",
},
},
}
configs.texlab.buf_build = buf_build

View File

@ -3,9 +3,9 @@ local util = require "lspconfig/util"
configs.tflint = {
default_config = {
cmd = {"tflint", "--langserver"},
filetypes = {"terraform"},
root_dir = util.root_pattern(".terraform", ".git", ".tflint.hcl")
cmd = { "tflint", "--langserver" },
filetypes = { "terraform" },
root_dir = util.root_pattern(".terraform", ".git", ".tflint.hcl"),
},
docs = {
description = [[
@ -15,8 +15,8 @@ A pluggable Terraform linter that can act as lsp server.
Installation instructions can be found in https://github.com/terraform-linters/tflint#installation.
]],
default_config = {
root_dir = [[root_pattern(".terraform", ".git", ".tflint.hcl")]]
}
}
root_dir = [[root_pattern(".terraform", ".git", ".tflint.hcl")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,21 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "tsserver"
local bin_name = "typescript-language-server"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..".cmd"
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".cmd"
end
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx"};
cmd = { bin_name, "--stdio" },
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
root_dir = function(fname)
return util.root_pattern("tsconfig.json")(fname) or
util.root_pattern("package.json", "jsconfig.json", ".git")(fname);
end
};
return util.root_pattern "tsconfig.json"(fname) or util.root_pattern("package.json", "jsconfig.json", ".git")(
fname
)
end,
},
docs = {
description = [[
https://github.com/theia-ide/typescript-language-server
@ -24,11 +25,11 @@ https://github.com/theia-ide/typescript-language-server
```sh
npm install -g typescript typescript-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]];
};
};
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -8,16 +8,16 @@ local fn = vim.fn
local M = {}
M.default_config = {
log_level = lsp.protocol.MessageType.Warning;
message_level = lsp.protocol.MessageType.Warning;
settings = vim.empty_dict();
init_options = vim.empty_dict();
handlers = {};
log_level = lsp.protocol.MessageType.Warning,
message_level = lsp.protocol.MessageType.Warning,
settings = vim.empty_dict(),
init_options = vim.empty_dict(),
handlers = {},
}
function M.validate_bufnr(bufnr)
validate {
bufnr = { bufnr, 'n' }
bufnr = { bufnr, "n" },
}
return bufnr == 0 and api.nvim_get_current_buf() or bufnr
end
@ -48,19 +48,21 @@ end
function M.create_module_commands(module_name, commands)
for command_name, def in pairs(commands) do
local parts = {"command!"}
local parts = { "command!" }
-- Insert attributes.
for k, v in pairs(def) do
if type(k) == 'string' and type(v) == 'boolean' and v then
table.insert(parts, "-"..k)
elseif type(k) == 'number' and type(v) == 'string' and v:match("^%-") then
if type(k) == "string" and type(v) == "boolean" and v then
table.insert(parts, "-" .. k)
elseif type(k) == "number" and type(v) == "string" and v:match "^%-" then
table.insert(parts, v)
end
end
table.insert(parts, command_name)
-- The command definition.
table.insert(parts,
string.format("lua require'lspconfig'[%q].commands[%q][1](<f-args>)", module_name, command_name))
table.insert(
parts,
string.format("lua require'lspconfig'[%q].commands[%q][1](<f-args>)", module_name, command_name)
)
api.nvim_command(table.concat(parts, " "))
end
end
@ -75,8 +77,8 @@ function M.has_bins(...)
end
M.script_path = function()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*[/\\])")
local str = debug.getinfo(2, "S").source:sub(2)
return str:match "(.*[/\\])"
end
-- Some path utilities
@ -87,20 +89,20 @@ M.path = (function()
end
local function is_dir(filename)
return exists(filename) == 'directory'
return exists(filename) == "directory"
end
local function is_file(filename)
return exists(filename) == 'file'
return exists(filename) == "file"
end
local is_windows = uv.os_uname().version:match("Windows")
local is_windows = uv.os_uname().version:match "Windows"
local path_sep = is_windows and "\\" or "/"
local is_fs_root
if is_windows then
is_fs_root = function(path)
return path:match("^%a:$")
return path:match "^%a:$"
end
else
is_fs_root = function(path)
@ -110,16 +112,16 @@ M.path = (function()
local function is_absolute(filename)
if is_windows then
return filename:match("^%a:") or filename:match("^\\\\")
return filename:match "^%a:" or filename:match "^\\\\"
else
return filename:match("^/")
return filename:match "^/"
end
end
local dirname
do
local strip_dir_pat = path_sep.."([^"..path_sep.."]+)$"
local strip_sep_pat = path_sep.."$"
local strip_dir_pat = path_sep .. "([^" .. path_sep .. "]+)$"
local strip_sep_pat = path_sep .. "$"
dirname = function(path)
if not path or #path == 0 then
return
@ -133,9 +135,7 @@ M.path = (function()
end
local function path_join(...)
local result =
table.concat(
vim.tbl_flatten {...}, path_sep):gsub(path_sep.."+", path_sep)
local result = table.concat(vim.tbl_flatten { ... }, path_sep):gsub(path_sep .. "+", path_sep)
return result
end
@ -146,7 +146,9 @@ M.path = (function()
-- Just in case our algo is buggy, don't infinite loop.
for _ = 1, 100 do
dir = dirname(dir)
if not dir then return end
if not dir then
return
end
-- If we can't ascend further, then stop looking.
if cb(dir, path) then
return dir, path
@ -161,42 +163,45 @@ M.path = (function()
local function iterate_parents(path)
path = uv.fs_realpath(path)
local function it(s, v)
if not v then return end
if is_fs_root(v) then return end
if not v then
return
end
if is_fs_root(v) then
return
end
return dirname(v), path
end
return it, path, path
end
local function is_descendant(root, path)
if (not path) then
return false;
if not path then
return false
end
local function cb(dir, _)
return dir == root;
return dir == root
end
local dir, _ = traverse_parents(path, cb);
local dir, _ = traverse_parents(path, cb)
return dir == root;
return dir == root
end
return {
is_dir = is_dir;
is_file = is_file;
is_absolute = is_absolute;
exists = exists;
sep = path_sep;
dirname = dirname;
join = path_join;
traverse_parents = traverse_parents;
iterate_parents = iterate_parents;
is_descendant = is_descendant;
is_dir = is_dir,
is_file = is_file,
is_absolute = is_absolute,
exists = exists,
sep = path_sep,
dirname = dirname,
join = path_join,
traverse_parents = traverse_parents,
iterate_parents = iterate_parents,
is_descendant = is_descendant,
}
end)()
-- Returns a function(root_dir), which, when called with a root_dir it hasn't
-- seen before, will call make_config(root_dir) and start a new client.
function M.server_per_root_dir_manager(_make_config)
@ -204,8 +209,12 @@ function M.server_per_root_dir_manager(_make_config)
local manager = {}
function manager.add(root_dir)
if not root_dir then return end
if not M.path.is_dir(root_dir) then return end
if not root_dir then
return
end
if not M.path.is_dir(root_dir) then
return
end
-- Check if we have a client alredy or start and store it.
local client_id = clients[root_dir]
@ -213,10 +222,15 @@ function M.server_per_root_dir_manager(_make_config)
local new_config = _make_config(root_dir)
--TODO:mjlbach -- these prints only show up with nvim_error_writeln()
if not new_config.cmd then
print(string.format("Error, cmd not defined for [%q]."..
"You must manually define a cmd for the default config for this server."
.."See server documentation.", new_config.name))
return
print(
string.format(
"Error, cmd not defined for [%q]."
.. "You must manually define a cmd for the default config for this server."
.. "See server documentation.",
new_config.name
)
)
return
elseif vim.fn.executable(new_config.cmd[1]) == 0 then
vim.notify(string.format("cmd [%q] is not executable.", new_config.cmd[1]), vim.log.levels.Error)
return
@ -245,15 +259,19 @@ function M.server_per_root_dir_manager(_make_config)
end
function M.search_ancestors(startpath, func)
validate { func = {func, 'f'} }
if func(startpath) then return startpath end
validate { func = { func, "f" } }
if func(startpath) then
return startpath
end
for path in M.path.iterate_parents(startpath) do
if func(path) then return path end
if func(path) then
return path
end
end
end
function M.root_pattern(...)
local patterns = vim.tbl_flatten {...}
local patterns = vim.tbl_flatten { ... }
local function matcher(path)
for _, pattern in ipairs(patterns) do
for _, p in ipairs(vim.fn.glob(M.path.join(path, pattern), true, true)) do
@ -289,6 +307,5 @@ function M.find_package_json_ancestor(startpath)
end)
end
return M
-- vim:et ts=2 sw=2

View File

@ -1,18 +1,18 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local meson_matcher = function (path)
local meson_matcher = function(path)
local pattern = "meson.build"
local f = vim.fn.glob(util.path.join(path, pattern))
if f == '' then
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
if not line:match "^%s*#.*" then
local str = line:gsub("%s+", "")
if str ~= "" then
if str:match "^project%(" then
return path
else
break
@ -24,17 +24,17 @@ end
configs.vala_ls = {
default_config = {
cmd = {'vala-language-server'},
filetypes = {'vala', 'genie'},
root_dir = function (fname)
cmd = { "vala-language-server" },
filetypes = { "vala", "genie" },
root_dir = function(fname)
local root = util.search_ancestors(fname, meson_matcher)
return root or util.find_git_ancestor(fname)
end,
},
docs = {
description = 'https://github.com/benwaffle/vala-language-server',
description = "https://github.com/benwaffle/vala-language-server",
default_config = {
root_dir = [[root_pattern("meson.build", ".git")]]
root_dir = [[root_pattern("meson.build", ".git")]],
},
},
}

View File

@ -1,16 +1,16 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "vimls"
local bin_name = "vim-language-server"
if vim.fn.has('win32') == 1 then
bin_name = bin_name..".cmd"
if vim.fn.has "win32" == 1 then
bin_name = bin_name .. ".cmd"
end
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"},
filetypes = {"vim"},
cmd = { bin_name, "--stdio" },
filetypes = { "vim" },
root_dir = function(fname)
return util.find_git_ancestor(fname) or vim.fn.getcwd()
end,
@ -18,14 +18,14 @@ configs[server_name] = {
iskeyword = "@,48-57,_,192-255,-#",
vimruntime = "",
runtimepath = "",
diagnostic = {enable = true},
diagnostic = { enable = true },
indexes = {
runtimepath = true,
gap = 100,
count = 3,
projectRootPatterns = {"runtime", "nvim", ".git", "autoload", "plugin"}
projectRootPatterns = { "runtime", "nvim", ".git", "autoload", "plugin" },
},
suggest = {fromVimruntime = true, fromRuntimepath = true}
suggest = { fromVimruntime = true, fromRuntimepath = true },
},
},
docs = {
@ -36,8 +36,8 @@ You can install vim-language-server via npm:
```sh
npm install -g vim-language-server
```
]]
}
]],
},
}
-- vim:et ts=2 sw=2

View File

@ -1,13 +1,13 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local name = "vls"
configs[name] = {
default_config = {
filetypes = {"vlang"};
root_dir = util.root_pattern("v.mod", ".git");
};
filetypes = { "vlang" },
root_dir = util.root_pattern("v.mod", ".git"),
},
docs = {
description = [[
https://github.com/vlang/vls
@ -27,10 +27,10 @@ require'lspconfig'.vls.setup {
cmd = {vls_binary},
}
```
]];
]],
default_config = {
root_dir = [[root_pattern("v.mod", ".git")]];
};
};
root_dir = [[root_pattern("v.mod", ".git")]],
},
},
}
-- vim:et ts=2

View File

@ -1,55 +1,55 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "vuels"
local bin_name = "vls"
configs[server_name] = {
default_config = {
cmd = {bin_name};
filetypes = {"vue"};
root_dir = util.root_pattern("package.json", "vue.config.js");
cmd = { bin_name },
filetypes = { "vue" },
root_dir = util.root_pattern("package.json", "vue.config.js"),
init_options = {
config = {
vetur = {
useWorkspaceDependencies = false;
useWorkspaceDependencies = false,
validation = {
template = true;
style = true;
script = true;
};
template = true,
style = true,
script = true,
},
completion = {
autoImport = false;
useScaffoldSnippets = false;
tagCasing = "kebab";
};
autoImport = false,
useScaffoldSnippets = false,
tagCasing = "kebab",
},
format = {
defaultFormatter = {
js = "none";
ts = "none";
};
defaultFormatterOptions = {};
scriptInitialIndent = false;
styleInitialIndent = false;
}
};
css = {};
js = "none",
ts = "none",
},
defaultFormatterOptions = {},
scriptInitialIndent = false,
styleInitialIndent = false,
},
},
css = {},
html = {
suggest = {};
};
suggest = {},
},
javascript = {
format = {};
};
format = {},
},
typescript = {
format = {};
};
emmet = {};
stylusSupremacy = {};
};
};
};
format = {},
},
emmet = {},
stylusSupremacy = {},
},
},
},
docs = {
package_json = "https://raw.githubusercontent.com/vuejs/vetur/master/package.json";
package_json = "https://raw.githubusercontent.com/vuejs/vetur/master/package.json",
description = [[
https://github.com/vuejs/vetur/tree/master/server
@ -58,49 +58,49 @@ Vue language server(vls)
```sh
npm install -g vls
```
]];
]],
default_config = {
root_dir = [[root_pattern("package.json", "vue.config.js")]];
root_dir = [[root_pattern("package.json", "vue.config.js")]],
init_options = {
config = {
vetur = {
useWorkspaceDependencies = false;
useWorkspaceDependencies = false,
validation = {
template = true;
style = true;
script = true;
};
template = true,
style = true,
script = true,
},
completion = {
autoImport = false;
useScaffoldSnippets = false;
tagCasing = "kebab";
};
autoImport = false,
useScaffoldSnippets = false,
tagCasing = "kebab",
},
format = {
defaultFormatter = {
js = "none";
ts = "none";
};
defaultFormatterOptions = {};
scriptInitialIndent = false;
styleInitialIndent = false;
}
};
css = {};
js = "none",
ts = "none",
},
defaultFormatterOptions = {},
scriptInitialIndent = false,
styleInitialIndent = false,
},
},
css = {},
html = {
suggest = {};
};
suggest = {},
},
javascript = {
format = {};
};
format = {},
},
typescript = {
format = {};
};
emmet = {};
stylusSupremacy = {};
};
};
};
};
format = {},
},
emmet = {},
stylusSupremacy = {},
},
},
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,17 +1,17 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "yamlls"
local bin_name = "yaml-language-server"
configs[server_name] = {
default_config = {
cmd = {bin_name, "--stdio"};
filetypes = {"yaml"};
root_dir = util.root_pattern(".git", vim.fn.getcwd());
};
cmd = { bin_name, "--stdio" },
filetypes = { "yaml" },
root_dir = util.root_pattern(".git", vim.fn.getcwd()),
},
docs = {
package_json = "https://raw.githubusercontent.com/redhat-developer/vscode-yaml/master/package.json";
package_json = "https://raw.githubusercontent.com/redhat-developer/vscode-yaml/master/package.json",
description = [[
https://github.com/redhat-developer/yaml-language-server
@ -19,11 +19,11 @@ https://github.com/redhat-developer/yaml-language-server
```sh
npm install -g yaml-language-server
```
]];
]],
default_config = {
root_dir = [[root_pattern(".git", vim.fn.getcwd())]];
};
};
root_dir = [[root_pattern(".git", vim.fn.getcwd())]],
},
},
}
-- vim:et ts=2 sw=2

View File

@ -1,15 +1,15 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local server_name = "zeta_note"
configs[server_name] = {
default_config = {
filetypes = {"markdown"};
root_dir = util.root_pattern(".zeta.toml");
};
filetypes = { "markdown" },
root_dir = util.root_pattern ".zeta.toml",
},
docs = {
package_json = "https://raw.githubusercontent.com/artempyanykh/zeta-note-vscode/main/package.json";
package_json = "https://raw.githubusercontent.com/artempyanykh/zeta-note-vscode/main/package.json",
description = [[
https://github.com/artempyanykh/zeta-note
@ -24,9 +24,9 @@ require'lspconfig'.zeta_note.setup{
cmd = {'path/to/zeta-note'}
}
```
]];
]],
default_config = {
root_dir = [[root_pattern(".zeta.toml")]];
};
};
root_dir = [[root_pattern(".zeta.toml")]],
},
},
}

View File

@ -1,22 +1,22 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
configs.zls = {
default_config = {
cmd = {"zls"};
filetypes = {"zig", "zir"};
root_dir = function(fname)
return util.root_pattern("zls.json", ".git")(fname) or util.path.dirname(fname)
end
};
docs = {
description = [[
default_config = {
cmd = { "zls" },
filetypes = { "zig", "zir" },
root_dir = function(fname)
return util.root_pattern("zls.json", ".git")(fname) or util.path.dirname(fname)
end,
},
docs = {
description = [[
https://github.com/zigtools/zls
`Zig LSP implementation + Zig Language Server`.
]];
default_config = {
root_dir = [[util.root_pattern("zls.json", ".git") or current_file_dirname]];
};
};
};
]],
default_config = {
root_dir = [[util.root_pattern("zls.json", ".git") or current_file_dirname]],
},
},
}

View File

@ -1,6 +1,6 @@
require 'lspconfig'
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
require "lspconfig"
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"
local inspect = vim.inspect
local uv = vim.loop
local fn = vim.fn
@ -23,26 +23,28 @@ end
local function indent(n, s)
local prefix
if type(n) == 'number' then
if n <= 0 then return s end
if type(n) == "number" then
if n <= 0 then
return s
end
prefix = string.rep(" ", n)
else
assert(type(n) == 'string', 'n must be number or string')
assert(type(n) == "string", "n must be number or string")
prefix = n
end
local lines = vim.split(s, '\n', true)
local lines = vim.split(s, "\n", true)
for i, line in ipairs(lines) do
lines[i] = prefix..line
lines[i] = prefix .. line
end
return table.concat(lines, '\n')
return table.concat(lines, "\n")
end
local function make_parts(fns)
return tbl_flatten(map_list(fns, function(v)
if type(v) == 'function' then
if type(v) == "function" then
v = v()
end
return {v}
return { v }
end))
end
@ -52,7 +54,7 @@ end
local function readfile(path)
assert(util.path.is_file(path))
return io.open(path):read("*a")
return io.open(path):read "*a"
end
local function sorted_map_table(t, func)
@ -82,165 +84,190 @@ require'lspconfig'.{{template_name}}.setup{}
local function require_all_configs()
-- Configs are lazy-loaded, tickle them to populate the `configs` singleton.
for _,v in ipairs(vim.fn.glob('lua/lspconfig/*.lua', 1, 1)) do
local module_name = v:gsub('.*/', ''):gsub('%.lua$', '')
require('lspconfig/'..module_name)
for _, v in ipairs(vim.fn.glob("lua/lspconfig/*.lua", 1, 1)) do
local module_name = v:gsub(".*/", ""):gsub("%.lua$", "")
require("lspconfig/" .. module_name)
end
end
local function make_lsp_sections()
return make_section(0, '\n', sorted_map_table(configs, function(template_name, template_object)
local template_def = template_object.document_config
local docs = template_def.docs
return make_section(
0,
"\n",
sorted_map_table(configs, function(template_name, template_object)
local template_def = template_object.document_config
local docs = template_def.docs
local params = {
template_name = template_name;
preamble = "";
body = "";
}
params.body = make_section(2, '\n\n', {
function()
if not template_def.commands then return end
return make_section(0, '\n', {
"Commands:";
sorted_map_table(template_def.commands, function(name, def)
if def.description then
return string.format("- %s: %s", name, def.description)
end
return string.format("- %s", name)
end)
})
end;
function()
if not template_def.default_config then return end
return make_section(0, '\n', {
"Default Values:";
sorted_map_table(template_def.default_config, function(k, v)
local description = ((docs or {}).default_config or {})[k]
if description and type(description) ~= 'string' then
description = inspect(description)
elseif not description and type(v) == "function" then
local info = debug.getinfo(v)
local file = io.open(string.sub(info.source, 2), 'r')
local fileContent = {}
for line in file:lines() do
table.insert (fileContent, line)
end
io.close(file)
local root_dir = {}
for i = info.linedefined, info.lastlinedefined do
table.insert(root_dir, fileContent[i])
end
description = table.concat(root_dir, '\n')
description = string.gsub(description, ".*function", "function")
end
return indent(2, string.format("%s = %s", k, description or inspect(v)))
end)
})
end;
})
if docs then
local tempdir = os.getenv("DOCGEN_TEMPDIR") or uv.fs_mkdtemp("/tmp/nvim-lsp.XXXXXX")
local preamble_parts = make_parts {
function()
if docs.description and #docs.description > 0 then
return docs.description
end
end;
function()
local package_json_name = util.path.join(tempdir, template_name..'.package.json');
if docs.package_json then
if not util.path.is_file(package_json_name) then
os.execute(string.format("curl -v -L -o %q %q", package_json_name, docs.package_json))
end
if not util.path.is_file(package_json_name) then
print(string.format("Failed to download package.json for %q at %q", template_name, docs.package_json))
os.exit(1)
return
end
local data = fn.json_decode(readfile(package_json_name))
-- The entire autogenerated section.
return make_section(0, '\n', {
-- The default settings section
function()
local default_settings = (data.contributes or {}).configuration
if not default_settings.properties then return end
-- The outer section.
return make_section(0, '\n', {
'This server accepts configuration via the `settings` key.';
'<details><summary>Available settings:</summary>';
'';
-- The list of properties.
make_section(0, '\n\n', sorted_map_table(default_settings.properties, function(k, v)
local function tick(s) return string.format("`%s`", s) end
local function bold(s) return string.format("**%s**", s) end
-- https://github.github.com/gfm/#backslash-escapes
local function excape_markdown_punctuations(str)
local pattern = "\\(\\*\\|\\.\\|?\\|!\\|\"\\|#\\|\\$\\|%\\|'\\|(\\|)\\|,\\|-\\|\\/\\|:\\|;\\|<\\|=\\|>\\|@\\|\\[\\|\\\\\\|\\]\\|\\^\\|_\\|`\\|{\\|\\\\|\\|}\\)"
return fn.substitute(str, pattern, "\\\\\\0", "g")
end
-- local function pre(s) return string.format("<pre>%s</pre>", s) end
-- local function code(s) return string.format("<code>%s</code>", s) end
if not (type(v) == "table") then
return
end
return make_section(0, '\n', {
"- "..make_section(0, ': ', {
bold(tick(k));
function()
if v.enum then
return tick("enum "..inspect(v.enum))
end
if v.type then
return tick(table.concat(tbl_flatten{v.type}, '|'))
end
end;
});
'';
make_section(2, '\n\n', {
{v.default and "Default: "..tick(inspect(v.default, {newline='';indent=''}))};
{v.items and "Array items: "..tick(inspect(v.items, {newline='';indent=''}))};
{excape_markdown_punctuations(v.description)};
});
})
end));
'';
'</details>';
})
end;
})
end
end
local params = {
template_name = template_name,
preamble = "",
body = "",
}
if not os.getenv("DOCGEN_TEMPDIR") then
os.execute("rm -rf "..tempdir)
end
-- Insert a newline after the preamble if it exists.
if #preamble_parts > 0 then table.insert(preamble_parts, '') end
params.preamble = table.concat(preamble_parts, '\n')
end
return template(lsp_section_template, params)
end))
params.body = make_section(2, "\n\n", {
function()
if not template_def.commands then
return
end
return make_section(0, "\n", {
"Commands:",
sorted_map_table(template_def.commands, function(name, def)
if def.description then
return string.format("- %s: %s", name, def.description)
end
return string.format("- %s", name)
end),
})
end,
function()
if not template_def.default_config then
return
end
return make_section(0, "\n", {
"Default Values:",
sorted_map_table(template_def.default_config, function(k, v)
local description = ((docs or {}).default_config or {})[k]
if description and type(description) ~= "string" then
description = inspect(description)
elseif not description and type(v) == "function" then
local info = debug.getinfo(v)
local file = io.open(string.sub(info.source, 2), "r")
local fileContent = {}
for line in file:lines() do
table.insert(fileContent, line)
end
io.close(file)
local root_dir = {}
for i = info.linedefined, info.lastlinedefined do
table.insert(root_dir, fileContent[i])
end
description = table.concat(root_dir, "\n")
description = string.gsub(description, ".*function", "function")
end
return indent(2, string.format("%s = %s", k, description or inspect(v)))
end),
})
end,
})
if docs then
local tempdir = os.getenv "DOCGEN_TEMPDIR" or uv.fs_mkdtemp "/tmp/nvim-lsp.XXXXXX"
local preamble_parts = make_parts {
function()
if docs.description and #docs.description > 0 then
return docs.description
end
end,
function()
local package_json_name = util.path.join(tempdir, template_name .. ".package.json")
if docs.package_json then
if not util.path.is_file(package_json_name) then
os.execute(string.format("curl -v -L -o %q %q", package_json_name, docs.package_json))
end
if not util.path.is_file(package_json_name) then
print(string.format("Failed to download package.json for %q at %q", template_name, docs.package_json))
os.exit(1)
return
end
local data = fn.json_decode(readfile(package_json_name))
-- The entire autogenerated section.
return make_section(0, "\n", {
-- The default settings section
function()
local default_settings = (data.contributes or {}).configuration
if not default_settings.properties then
return
end
-- The outer section.
return make_section(0, "\n", {
"This server accepts configuration via the `settings` key.",
"<details><summary>Available settings:</summary>",
"",
-- The list of properties.
make_section(
0,
"\n\n",
sorted_map_table(default_settings.properties, function(k, v)
local function tick(s)
return string.format("`%s`", s)
end
local function bold(s)
return string.format("**%s**", s)
end
-- https://github.github.com/gfm/#backslash-escapes
local function excape_markdown_punctuations(str)
local pattern =
"\\(\\*\\|\\.\\|?\\|!\\|\"\\|#\\|\\$\\|%\\|'\\|(\\|)\\|,\\|-\\|\\/\\|:\\|;\\|<\\|=\\|>\\|@\\|\\[\\|\\\\\\|\\]\\|\\^\\|_\\|`\\|{\\|\\\\|\\|}\\)"
return fn.substitute(str, pattern, "\\\\\\0", "g")
end
-- local function pre(s) return string.format("<pre>%s</pre>", s) end
-- local function code(s) return string.format("<code>%s</code>", s) end
if not (type(v) == "table") then
return
end
return make_section(0, "\n", {
"- " .. make_section(0, ": ", {
bold(tick(k)),
function()
if v.enum then
return tick("enum " .. inspect(v.enum))
end
if v.type then
return tick(table.concat(tbl_flatten { v.type }, "|"))
end
end,
}),
"",
make_section(2, "\n\n", {
{ v.default and "Default: " .. tick(inspect(v.default, { newline = "", indent = "" })) },
{ v.items and "Array items: " .. tick(inspect(v.items, { newline = "", indent = "" })) },
{ excape_markdown_punctuations(v.description) },
}),
})
end)
),
"",
"</details>",
})
end,
})
end
end,
}
if not os.getenv "DOCGEN_TEMPDIR" then
os.execute("rm -rf " .. tempdir)
end
-- Insert a newline after the preamble if it exists.
if #preamble_parts > 0 then
table.insert(preamble_parts, "")
end
params.preamble = table.concat(preamble_parts, "\n")
end
return template(lsp_section_template, params)
end)
)
end
local function make_implemented_servers_list()
return make_section(0, '\n', sorted_map_table(configs, function(k)
return template("- [{{server}}](#{{server}})", {server=k})
end))
return make_section(
0,
"\n",
sorted_map_table(configs, function(k)
return template("- [{{server}}](#{{server}})", { server = k })
end)
)
end
local function generate_readme(template_file, params)
vim.validate {
lsp_server_details = {params.lsp_server_details, 's'};
implemented_servers_list = {params.implemented_servers_list, 's'};
lsp_server_details = { params.lsp_server_details, "s" },
implemented_servers_list = { params.implemented_servers_list, "s" },
}
local input_template = readfile(template_file)
local readme_data = template(input_template, params)
@ -252,8 +279,8 @@ end
require_all_configs()
generate_readme("scripts/README_template.md", {
implemented_servers_list = make_implemented_servers_list();
lsp_server_details = make_lsp_sections();
implemented_servers_list = make_implemented_servers_list(),
lsp_server_details = make_lsp_sections(),
})
-- vim:et ts=2 sw=2

View File

@ -1,4 +1,4 @@
local docgen = require('babelfish')
local docgen = require "babelfish"
local docs = {}
@ -8,14 +8,14 @@ docs.generate = function()
output_file = "./doc/lspconfig.txt",
project_name = "lspconfig",
header_aliases = {
["Example: using the defaults"] = {"Defaults", "defaults"},
["Example: override some defaults"] = {"Overriding server defaults", "override-server-defaults"},
["Example: custom config"] = {"Custom config", "custom-config"},
["Example: override default config for all servers"] = {"Overriding all defaults", "override-all-defaults"},
["Individual server settings and initialization options"] = { "Per-server documentation", "server-documentation"},
["Keybindings and completion"] = {"Keybindings", "keybindings"},
["Manually starting (or restarting) language servers"] = {"Manual control", "manual-control"}
}
["Example: using the defaults"] = { "Defaults", "defaults" },
["Example: override some defaults"] = { "Overriding server defaults", "override-server-defaults" },
["Example: custom config"] = { "Custom config", "custom-config" },
["Example: override default config for all servers"] = { "Overriding all defaults", "override-all-defaults" },
["Individual server settings and initialization options"] = { "Per-server documentation", "server-documentation" },
["Keybindings and completion"] = { "Keybindings", "keybindings" },
["Manually starting (or restarting) language servers"] = { "Manual control", "manual-control" },
},
}
docgen.generate_readme(metadata)
end

View File

@ -1,4 +1,4 @@
local helpers = require('test.functional.helpers')(after_each)
local helpers = require "test.functional.helpers"(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
@ -7,35 +7,38 @@ local ok = helpers.ok
before_each(function()
clear()
-- add plugin module path to package.path in Lua runtime in Nvim
exec_lua([[
exec_lua(
[[
package.path = ...
]], package.path)
]],
package.path
)
end)
describe('lspconfig', function()
describe('util', function()
describe('path', function()
describe('exists', function()
it('is present directory', function()
ok(exec_lua([[
describe("lspconfig", function()
describe("util", function()
describe("path", function()
describe("exists", function()
it("is present directory", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local cwd = vim.fn.getcwd()
return not (lspconfig.util.path.exists(cwd) == false)
]]))
]])
end)
it('is not present directory', function()
ok(exec_lua([[
it("is not present directory", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local not_exist_dir = vim.fn.getcwd().."/not/exsts"
return lspconfig.util.path.exists(not_exist_dir) == false
]]))
]])
end)
it('is present file', function()
ok(exec_lua([[
it("is present file", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -43,11 +46,11 @@ describe('lspconfig', function()
local file = vim.fn.getcwd().."/root_marker.txt"
return not (lspconfig.util.path.exists(file) == false)
]]))
]])
end)
it('is not present file', function()
ok(exec_lua([[
it("is not present file", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -55,31 +58,31 @@ describe('lspconfig', function()
local file = vim.fn.getcwd().."/not_exists.txt"
return lspconfig.util.path.exists(file) == false
]]))
]])
end)
end)
describe('is_dir', function()
it('is directory', function()
ok(exec_lua([[
describe("is_dir", function()
it("is directory", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local cwd = vim.fn.getcwd()
return lspconfig.util.path.is_dir(cwd)
]]))
]])
end)
it('is not present directory', function()
ok(exec_lua([[
it("is not present directory", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local not_exist_dir = vim.fn.getcwd().."/not/exsts"
return not lspconfig.util.path.is_dir(not_exist_dir)
]]))
]])
end)
it('is file', function()
ok(exec_lua([[
it("is file", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -87,13 +90,13 @@ describe('lspconfig', function()
local file = vim.fn.getcwd().."/root_marker.txt"
return not lspconfig.util.path.is_dir(file)
]]))
]])
end)
end)
describe('is_file', function()
it('is file', function()
ok(exec_lua([[
describe("is_file", function()
it("is file", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -101,11 +104,11 @@ describe('lspconfig', function()
local file = vim.fn.getcwd().."/root_marker.txt"
return lspconfig.util.path.is_file(file)
]]))
]])
end)
it('is not present file', function()
ok(exec_lua([[
it("is not present file", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -113,64 +116,67 @@ describe('lspconfig', function()
local file = vim.fn.getcwd().."/not_exists.txt"
return not lspconfig.util.path.is_file(file)
]]))
]])
end)
it('is directory', function()
ok(exec_lua([[
it("is directory", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
local cwd = vim.fn.getcwd()
return not lspconfig.util.path.is_file(cwd)
]]))
]])
end)
end)
describe('is_absolute', function()
it('is absolute', function()
ok(exec_lua([[
describe("is_absolute", function()
it("is absolute", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return not (lspconfig.util.path.is_absolute("/foo/bar") == nil)
]]))
]])
end)
it('is not absolute', function()
ok(exec_lua([[
it("is not absolute", function()
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.path.is_absolute("foo/bar") == nil
]]))
]])
ok(exec_lua([[
ok(exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.path.is_absolute("../foo/bar") == nil
]]))
]])
end)
end)
describe('join', function()
it('', function()
eq(exec_lua([[
describe("join", function()
it("", function()
eq(
exec_lua [[
local lspconfig = require("lspconfig")
return lspconfig.util.path.join("foo", "bar", "baz")
]]), "foo/bar/baz")
]],
"foo/bar/baz"
)
end)
end)
end)
describe('root_pattern', function()
describe("root_pattern", function()
it("resolves to a_marker.txt", function()
ok(exec_lua([[
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
vim.api.nvim_command("cd ../test/test_dir/a")
local cwd = vim.fn.getcwd()
return cwd == lspconfig.util.root_pattern({"root_marker.txt", "a_marker.txt"})(cwd)
]]))
]])
end)
it("resolves to root_marker.txt", function()
ok(exec_lua([[
ok(exec_lua [[
local lspconfig = require("lspconfig")
-- change the working directory to test directory
@ -181,7 +187,7 @@ describe('lspconfig', function()
vim.api.nvim_command("cd ..")
return vim.fn.getcwd() == resolved
]]))
]])
end)
end)
end)

View File

@ -1,75 +1,77 @@
-- install packer
local fn = vim.fn
local install_path = '/tmp/nvim/site/pack/packer/start/packer.nvim'
local install_path = "/tmp/nvim/site/pack/packer/start/packer.nvim"
vim.cmd [[set packpath=/tmp/nvim/site]]
local function load_plugins()
local use = require('packer').use
require("packer").startup(
{
function()
use 'wbthomason/packer.nvim'
use "neovim/nvim-lspconfig"
end,
config = {package_root = '/tmp/nvim/site/pack'}
}
)
local use = require("packer").use
require("packer").startup {
function()
use "wbthomason/packer.nvim"
use "neovim/nvim-lspconfig"
end,
config = { package_root = "/tmp/nvim/site/pack" },
}
end
_G.load_config = function()
vim.lsp.set_log_level("trace")
local nvim_lsp = require('lspconfig')
vim.lsp.set_log_level "trace"
local nvim_lsp = require "lspconfig"
local on_attach = function(_, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = { noremap=true, silent=true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
local opts = { noremap = true, silent = true }
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
end
-- Add the server that troubles you here
local name = "pyright"
local cmd = { "pyright-langserver", "--stdio"} -- needed for elixirls, omnisharp, sumneko_lua
local cmd = { "pyright-langserver", "--stdio" } -- needed for elixirls, omnisharp, sumneko_lua
if not name then
print("You have not defined a server name, please edit minimal_init.lua")
print "You have not defined a server name, please edit minimal_init.lua"
end
if not nvim_lsp[name].document_config.default_config.cmd and (not cmd) then
print([[You have not defined a server default cmd for a server
that requires it please edit minimal_init.lua]])
if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
print [[You have not defined a server default cmd for a server
that requires it please edit minimal_init.lua]]
end
nvim_lsp[name].setup {
cmd = cmd,
on_attach = on_attach,
}
cmd = cmd,
on_attach = on_attach,
}
print([[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]])
end
print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end
if fn.isdirectory(install_path) == 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
load_plugins()
require('packer').sync()
vim.cmd 'autocmd User PackerComplete ++once lua load_config()'
require("packer").sync()
vim.cmd "autocmd User PackerComplete ++once lua load_config()"
else
load_plugins()
_G.load_config()