mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-18 21:17:23 +00:00
lsp/presets/ccls: init
This commit is contained in:
parent
e439bf45b9
commit
d44cb76b26
2 changed files with 55 additions and 0 deletions
54
modules/plugins/lsp/presets/ccls.nix
Normal file
54
modules/plugins/lsp/presets/ccls.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
||||||
|
cfg = config.vim.lsp.presets.ccls;
|
||||||
|
in {
|
||||||
|
options.vim.lsp.presets.ccls = {
|
||||||
|
enable = mkEnableOption "the CC Language Server";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim.lsp.servers.ccls = {
|
||||||
|
enable = true;
|
||||||
|
cmd = [(getExe pkgs.ccls)];
|
||||||
|
offset_encoding = "utf-32";
|
||||||
|
root_markers = [".git" ".ccls" "compile_commands.json"];
|
||||||
|
workspace_required = true;
|
||||||
|
on_attach = mkLuaInline ''
|
||||||
|
function(client, bufnr)
|
||||||
|
local function switch_source_header(bufnr)
|
||||||
|
local method_name = "textDocument/switchSourceHeader"
|
||||||
|
local params = vim.lsp.util.make_text_document_params(bufnr)
|
||||||
|
client:request(method_name, params, function(err, result)
|
||||||
|
if err then
|
||||||
|
error(tostring(err))
|
||||||
|
end
|
||||||
|
if not result then
|
||||||
|
vim.notify('corresponding file cannot be determined')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.cmd.edit(vim.uri_to_fname(result))
|
||||||
|
end, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(
|
||||||
|
bufnr,
|
||||||
|
"LspCclsSwitchSourceHeader",
|
||||||
|
function(arg)
|
||||||
|
switch_source_header(client, 0)
|
||||||
|
end,
|
||||||
|
{desc = "Switch between source/header"}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
./astro-language-server.nix
|
./astro-language-server.nix
|
||||||
./basedpyright.nix
|
./basedpyright.nix
|
||||||
./bash-language-server.nix
|
./bash-language-server.nix
|
||||||
|
./ccls.nix
|
||||||
./clojure-lsp.nix
|
./clojure-lsp.nix
|
||||||
./cue.nix
|
./cue.nix
|
||||||
./dart.nix
|
./dart.nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue