Compare commits

...

11 commits

Author SHA1 Message Date
Soliprem
95ce28e3e4
Merge 68ad67369e into 42c5228dc1 2024-10-30 17:22:09 -04:00
raf
42c5228dc1
Merge pull request #428 from diniamo/add-csharp
languages/csharp: init
2024-10-28 12:56:53 +00:00
diniamo
665feee445 languages: csharp init with omnisharp and csharp_ls 2024-10-27 14:35:17 +01:00
diniamo
0aa557dac6 lsp: avoid vimscript in bindings 2024-10-27 14:31:13 +01:00
diniamo
5ab1af9285 languages/kotlin: allow specifying a command for lsp.package, fix indentation 2024-10-27 12:54:39 +01:00
diniamo
30a8a8fce0 languages/nix: use stricter type for lsp.server 2024-10-27 12:53:44 +01:00
Soliprem
da86e554a6
Fix typo in otter setupOpts (#424)
* Revert "leap: changed default binds"

This reverts commit 92a7bfc4b8.

* Reapply "leap: changed default binds"

This reverts commit ede1d4437e2d8d1a6ff31b4dc855676c6e16df36.

* otter: fixed stupid typo

* otter: added changelog entry
2024-10-23 14:51:43 +00:00
Anthony
71e2ae1db4
languages/nix: change nixpkgs-fmt to nixfmt (rfc-style) (#383) 2024-10-22 21:44:18 +00:00
Anthony
e80520ddf3
languages: add biome support for formatting (#423) 2024-10-22 22:15:07 +02:00
diniamo
3c4eced9d1
docs: add missing deprecation notes (#420) 2024-10-17 15:19:37 +02:00
diniamo
ff9b0eeb1f
nvim-cmp: fix rewrite remnants (#419)
* fix: bad cmp confirm

* nvim-cmp: simplify confirm bind and mapping definitions

---------

Co-authored-by: Pei Yang Ching <59727193+horriblename@users.noreply.github.com>
2024-10-17 05:57:29 +00:00
14 changed files with 300 additions and 69 deletions

View file

@ -75,6 +75,7 @@ isMaximal: {
enable = isMaximal;
crates.enable = isMaximal;
};
csharp.enable = isMaximal;
};
visuals = {

View file

@ -63,6 +63,24 @@ Note that we are looking to add more alternatives in the future like
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
everyone.
### `type` based modules removed {#sec-type-based-modules-removed}
As part of the autocompletion rewrite, modules that used to use a `type` option
have been replaced by per-plugin modules instead. Since both modules only had
one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation}
`nixpkgs-fmt` has been archived for a while, and it's finally being removed in
favor of nixfmt (more information can be found
[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs).
To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
`nixfmt`.
## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae):
@ -171,6 +189,9 @@ everyone.
- Add sorting function options for completion sources under
[](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators)
- Add C# support under `vim.languages.csharp`, with support for both
omnisharp-roslyn and csharp-language-server.
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
- Make Neovim's configuration file entirely Lua based. This comes with a few
@ -279,3 +300,11 @@ everyone.
- Add LSP support for Scala via
[nvim-metals](https://github.com/scalameta/nvim-metals)
[nezia1](https://github.com/nezia1):
- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and
Svelte. Enable them via [](#opt-vim.languages.ts.format.type),
[](#opt-vim.languages.css.format.type) and
[](#opt-vim.languages.svelte.format.type) respectively.
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with
[nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).

View file

@ -460,6 +460,22 @@
"type": "github"
}
},
"plugin-csharpls-extended": {
"flake": false,
"locked": {
"lastModified": 1728438370,
"narHash": "sha256-sOLPV5IhOvQ0+u7CDAfG3X0ZbRCicz18QyYXQ0dxpwQ=",
"owner": "Decodetalkers",
"repo": "csharpls-extended-lsp.nvim",
"rev": "b647e1bd1f9c0410f5ef4a1517a331cbac322d9a",
"type": "github"
},
"original": {
"owner": "Decodetalkers",
"repo": "csharpls-extended-lsp.nvim",
"type": "github"
}
},
"plugin-dashboard-nvim": {
"flake": false,
"locked": {
@ -1453,6 +1469,22 @@
"type": "github"
}
},
"plugin-omnisharp-extended": {
"flake": false,
"locked": {
"lastModified": 1719701797,
"narHash": "sha256-P1ZCaW8w+e3H3oBhbEjDc7vuR+XuxJmb/7IbPL3KWi4=",
"owner": "Hoffs",
"repo": "omnisharp-extended-lsp.nvim",
"rev": "aad7bf06b4ca0de816b919d475a75b30f5f62b61",
"type": "github"
},
"original": {
"owner": "Hoffs",
"repo": "omnisharp-extended-lsp.nvim",
"type": "github"
}
},
"plugin-onedark": {
"flake": false,
"locked": {
@ -1948,6 +1980,7 @@
"plugin-copilot-cmp": "plugin-copilot-cmp",
"plugin-copilot-lua": "plugin-copilot-lua",
"plugin-crates-nvim": "plugin-crates-nvim",
"plugin-csharpls-extended": "plugin-csharpls-extended",
"plugin-dashboard-nvim": "plugin-dashboard-nvim",
"plugin-diffview-nvim": "plugin-diffview-nvim",
"plugin-dracula": "plugin-dracula",
@ -2010,6 +2043,7 @@
"plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag",
"plugin-nvim-web-devicons": "plugin-nvim-web-devicons",
"plugin-obsidian-nvim": "plugin-obsidian-nvim",
"plugin-omnisharp-extended": "plugin-omnisharp-extended",
"plugin-onedark": "plugin-onedark",
"plugin-orgmode-nvim": "plugin-orgmode-nvim",
"plugin-otter-nvim": "plugin-otter-nvim",

View file

@ -215,6 +215,16 @@
flake = false;
};
plugin-omnisharp-extended = {
url = "github:Hoffs/omnisharp-extended-lsp.nvim";
flake = false;
};
plugin-csharpls-extended = {
url = "github:Decodetalkers/csharpls-extended-lsp.nvim";
flake = false;
};
# Copying/Registers
plugin-registers = {
url = "github:tversteeg/registers.nvim";

View file

@ -31,6 +31,11 @@ in {
vim.autocomplete.type has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'')
(mkRemovedOptionModule ["vim" "autocomplete" "sources"] ''
vim.autocomplete.sources has been removed in favor of per-plugin modules.
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
instead.
'')
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
'')

View file

@ -6,17 +6,13 @@
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) addDescriptionsToMappings;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) attrNames;
cfg = config.vim.autocomplete.nvim-cmp;
luasnipEnable = config.vim.snippets.luasnip.enable;
self = import ./nvim-cmp.nix {inherit lib config;};
mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
inherit (cfg) mappings;
in {
config = mkIf cfg.enable {
vim = {
@ -45,39 +41,20 @@ in {
};
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
local luasnip = require("luasnip")
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
cmp.setup(${toLuaObject cfg.setupOpts})
'');
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
autocomplete.nvim-cmp.setupOpts.mapping = {
${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()";
${mappings.close.value} = mkLuaInline "cmp.mapping.abort()";
${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
${mappings.confirm.value} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
${
if luasnipEnable
then ''
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({ select = true })
end
''
else "cmp.confirm({ select = true })"
}
else
fallback()
end
end)
'';
${mappings.next.value} = mkLuaInline ''
${mappings.next} = mkLuaInline ''
cmp.mapping(function(fallback)
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
@ -98,7 +75,7 @@ in {
end)
'';
${mappings.previous.value} = mkLuaInline ''
${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()

View file

@ -0,0 +1,122 @@
{
lib,
pkgs,
config,
options,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) either listOf package str enum;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
lspKeyConfig = config.vim.lsp.mappings;
lspKeyOptions = options.vim.lsp.mappings;
mkLspBinding = optionName: action: let
key = lspKeyConfig.${optionName};
desc = lspKeyOptions.${optionName}.description;
in
optionalString (key != null) "vim.keymap.set('n', '${key}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${desc}'})";
# Omnisharp doesn't have colors in popup docs for some reason, and I've also
# seen mentions of it being way slower, so until someone finds missing
# functionality, this will be the default.
defaultServer = "csharp_ls";
servers = {
omnisharp = {
package = pkgs.omnisharp-roslyn;
internalFormatter = true;
lspConfig = ''
lspconfig.omnisharp.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
default_on_attach(client, bufnr)
local oe = require("omnisharp_extended")
${mkLspBinding "goToDefinition" "oe.lsp_definition"}
${mkLspBinding "goToType" "oe.lsp_type_definition"}
${mkLspBinding "listReferences" "oe.lsp_references"}
${mkLspBinding "listImplementations" "oe.lsp_implementation"}
end,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/OmniSharp'}"
}
}
'';
};
csharp_ls = {
package = pkgs.csharp-ls;
internalFormatter = true;
lspConfig = ''
local extended_handler = require("csharpls_extended").handler
lspconfig.csharp_ls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
handlers = {
["textDocument/definition"] = extended_handler,
["textDocument/typeDefinition"] = extended_handler
},
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/csharp-ls'}"
}
}
'';
};
};
extraServerPlugins = {
omnisharp = ["omnisharp-extended"];
csharp_ls = ["csharpls-extended"];
};
cfg = config.vim.languages.csharp;
in {
options = {
vim.languages.csharp = {
enable = mkEnableOption "C# language support";
treesitter = {
enable = mkEnableOption "C# treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "c-sharp";
};
lsp = {
enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "C# LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "C# LSP server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.startPlugins = extraServerPlugins.${cfg.lsp.server} or [];
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.csharp-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -63,6 +63,18 @@
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
in {
options.vim.languages.css = {

View file

@ -28,6 +28,7 @@ in {
./ts.nix
./typst.nix
./zig.nix
./csharp.nix
];
options.vim.languages = {

View file

@ -8,7 +8,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.types) package;
inherit (lib.types) either package listOf str;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.lists) isList;
inherit (lib.nvim.lua) expToLua;
@ -43,12 +43,12 @@ in {
package = mkOption {
description = "kotlin_language_server package with Kotlin runtime";
type = package;
type = either package (listOf str);
example = literalExpression ''
pkgs.symlinkJoin {
name = "kotlin-language-server-wrapped";
paths = [pkgs.kotlin-language-server];
nativeBuildInputs = [pkgs.makeWrapper];
nativeBuildInputs = [pkgs.makeBinaryWrapper];
postBuild = '''
wrapProgram $out/bin/kotlin-language-server \
--prefix PATH : ''${pkgs.kotlin}/bin

View file

@ -5,6 +5,7 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib) concatStringsSep;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
@ -62,10 +63,10 @@
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
},
''}
${optionalString (cfg.format.type == "nixpkgs-fmt")
${optionalString (cfg.format.type == "nixfmt")
''
formatting = {
command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
command = {"${cfg.format.package}/bin/nixfmt"},
},
''}
},
@ -90,10 +91,19 @@
'';
};
nixpkgs-fmt = {
package = pkgs.nixpkgs-fmt;
# Never need to use null-ls for nixpkgs-fmt
nixfmt = {
package = pkgs.nixfmt-rfc-style;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.nixfmt.with({
command = "${cfg.format.package}/bin/nixfmt"
})
)
'';
};
nixpkgs-fmt = null; # removed
};
defaultDiagnosticsProvider = ["statix" "deadnix"];
@ -135,7 +145,7 @@ in {
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Nix LSP server to use";
type = str;
type = enum (attrNames servers);
default = defaultServer;
};
@ -175,6 +185,12 @@ in {
config = mkIf cfg.enable (mkMerge [
{
assertions = [
{
assertion = cfg.format.type != "nixpkgs-fmt";
message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}";
}
];
vim.pluginRC.nix = ''
vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",

View file

@ -48,6 +48,18 @@
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages

View file

@ -95,6 +95,18 @@
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages

View file

@ -18,7 +18,7 @@
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
mkBinding = binding: action:
if binding.value != null
then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})"
else "";
in {
config = mkIf cfg.enable {
@ -31,26 +31,26 @@ in {
vim.g.formatsave = ${boolToString cfg.formatOnSave};
local attach_keymaps = function(client, bufnr)
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"}
${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"}
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
${mkBinding mappings.hover "vim.lsp.buf.hover()"}
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
${mkBinding mappings.format "vim.lsp.buf.format()"}
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration"}
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition"}
${mkBinding mappings.goToType "vim.lsp.buf.type_definition"}
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation"}
${mkBinding mappings.listReferences "vim.lsp.buf.references"}
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next"}
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev"}
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float"}
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight"}
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol"}
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder"}
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder"}
${mkBinding mappings.listWorkspaceFolders "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"}
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol"}
${mkBinding mappings.hover "vim.lsp.buf.hover"}
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help"}
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename"}
${mkBinding mappings.codeAction "vim.lsp.buf.code_action"}
${mkBinding mappings.format "vim.lsp.buf.format"}
${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"}
end
-- Enable formatting