mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/nvim-lsp: add per-server onAttach option (#341)
This commit is contained in:
parent
838f616f0a
commit
bc468178ae
3 changed files with 39 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
||||||
# This file was generated by nvfetcher, please do not modify it manually.
|
# This file was generated by nvfetcher, please do not modify it manually.
|
||||||
{ fetchgit, fetchurl, fetchFromGitHub, dockerTools }:
|
|
||||||
{
|
{
|
||||||
|
fetchgit,
|
||||||
|
fetchurl,
|
||||||
|
fetchFromGitHub,
|
||||||
|
dockerTools,
|
||||||
|
}: {
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,24 @@
|
||||||
`:LspStart` (|lspconfig-commands|).
|
`:LspStart` (|lspconfig-commands|).
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
onAttach =
|
||||||
|
helpers.mkCompositeOption "Server specific on_attach behavior."
|
||||||
|
{
|
||||||
|
override = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Override the global `plugins.lsp.onAttach` function.";
|
||||||
|
};
|
||||||
|
|
||||||
|
function = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = ''
|
||||||
|
Body of the on_attach function.
|
||||||
|
The argument `client` and `bufnr` is provided.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
settings = settingsOptions;
|
settings = settingsOptions;
|
||||||
|
|
||||||
extraSettings = mkOption {
|
extraSettings = mkOption {
|
||||||
|
@ -82,6 +100,16 @@
|
||||||
name = serverName;
|
name = serverName;
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
inherit (cfg) cmd filetypes autostart;
|
inherit (cfg) cmd filetypes autostart;
|
||||||
|
on_attach =
|
||||||
|
helpers.ifNonNull' cfg.onAttach
|
||||||
|
(
|
||||||
|
helpers.mkRaw ''
|
||||||
|
function(client, bufnr)
|
||||||
|
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
|
||||||
|
${cfg.onAttach.function}
|
||||||
|
end
|
||||||
|
''
|
||||||
|
);
|
||||||
settings = (settings cfg.settings) // cfg.extraSettings;
|
settings = (settings cfg.settings) // cfg.extraSettings;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,12 @@
|
||||||
|
|
||||||
servers = {
|
servers = {
|
||||||
bashls.enable = true;
|
bashls.enable = true;
|
||||||
clangd.enable = true;
|
clangd = {
|
||||||
|
enable = true;
|
||||||
|
onAttach.function = ''
|
||||||
|
print('The clangd language server has been attached !')
|
||||||
|
'';
|
||||||
|
};
|
||||||
nil_ls.enable = true;
|
nil_ls.enable = true;
|
||||||
rust-analyzer.enable = true;
|
rust-analyzer.enable = true;
|
||||||
pylsp = {
|
pylsp = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue