mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 11:55:22 +00:00
lsp/presets/csharp_ls: int
This commit is contained in:
parent
4139469926
commit
f4423f18ab
2 changed files with 52 additions and 0 deletions
51
modules/plugins/lsp/presets/csharp_ls.nix
Normal file
51
modules/plugins/lsp/presets/csharp_ls.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.nvim.types) mkLspPresetEnableOption;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
||||||
|
cfg = config.vim.lsp.presets.csharp_ls;
|
||||||
|
in {
|
||||||
|
# HACK: this server should be named `csharp-ls`, but the extension `csharpls-extended-lsp-nvim` only works if it is named `csharp_ls`
|
||||||
|
options.vim.lsp.presets.csharp_ls = {
|
||||||
|
enable = mkLspPresetEnableOption "csharp_ls" "C#" [];
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.lsp.servers.csharp_ls = {
|
||||||
|
cmd = mkLuaInline ''
|
||||||
|
function(dispatchers, config)
|
||||||
|
return vim.lsp.rpc.start({ '${getExe pkgs.csharp-ls}', '--features', 'razor-support' , '--features', 'metadata-uris'}, dispatchers, {
|
||||||
|
-- csharp-ls attempt to locate sln, slnx or csproj files from cwd, so set cwd to root directory.
|
||||||
|
-- If cmd_cwd is provided, use it instead.
|
||||||
|
cwd = config.cmd_cwd or config.root_dir,
|
||||||
|
env = config.cmd_env,
|
||||||
|
detached = config.detached,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
root_dir = mkLuaInline ''
|
||||||
|
function(bufnr, on_dir)
|
||||||
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
on_dir(util.root_pattern '*.sln'(fname) or util.root_pattern '*.slnx'(fname) or util.root_pattern '*.csproj'(fname))
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
init_options = {
|
||||||
|
AutomaticWorkspaceInit = true;
|
||||||
|
};
|
||||||
|
get_language_id = mkLuaInline ''
|
||||||
|
function(_, ft)
|
||||||
|
if ft == 'cs' then
|
||||||
|
return 'csharp'
|
||||||
|
end
|
||||||
|
return ft
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
./ccls.nix
|
./ccls.nix
|
||||||
./clangd.nix
|
./clangd.nix
|
||||||
./clojure-lsp.nix
|
./clojure-lsp.nix
|
||||||
|
./csharp_ls.nix
|
||||||
./cue.nix
|
./cue.nix
|
||||||
./dart.nix
|
./dart.nix
|
||||||
./deno.nix
|
./deno.nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue