mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
languages/cmake: init
This commit is contained in:
parent
c7a4e99837
commit
16ba7cb6c3
3 changed files with 99 additions and 0 deletions
|
@ -392,10 +392,12 @@
|
||||||
[everforest]: https://github.com/sainnhe/everforest
|
[everforest]: https://github.com/sainnhe/everforest
|
||||||
[oil]: https://github.com/stevearc/oil.nvim
|
[oil]: https://github.com/stevearc/oil.nvim
|
||||||
[oil-git-status]: https://github.com/refractalize/oil-git-status.nvim
|
[oil-git-status]: https://github.com/refractalize/oil-git-status.nvim
|
||||||
|
[neocmakelsp]: https://github.com/neocmakelsp/neocmakelsp
|
||||||
|
|
||||||
- Fix gitsigns null-ls issue.
|
- Fix gitsigns null-ls issue.
|
||||||
- Add [everforest] theme support.
|
- Add [everforest] theme support.
|
||||||
- Add [oil-git-status] support to [oil] module.
|
- Add [oil-git-status] support to [oil] module.
|
||||||
|
- Add CMake support with [neocmakelsp].
|
||||||
|
|
||||||
[Haskex](https://github.com/haskex):
|
[Haskex](https://github.com/haskex):
|
||||||
|
|
||||||
|
|
96
modules/plugins/languages/cmake.nix
Normal file
96
modules/plugins/languages/cmake.nix
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.types) enum listOf package;
|
||||||
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.cmake;
|
||||||
|
|
||||||
|
defaultServers = ["neocmakelsp"];
|
||||||
|
servers = {
|
||||||
|
neocmakelsp = {
|
||||||
|
enable = true;
|
||||||
|
cmd = [(getExe pkgs.neocmakelsp) "--stdio"];
|
||||||
|
filetypes = ["cmake"];
|
||||||
|
root_markers = [".gersemirc" ".git" "build" "cmake"];
|
||||||
|
capabilities = {
|
||||||
|
textDocument.completion.completionItem.snippetSupport = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultFormat = "gersemi";
|
||||||
|
formats = {
|
||||||
|
gersemi = {
|
||||||
|
package = pkgs.gersemi;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.cmake = {
|
||||||
|
enable = mkEnableOption "CMake language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = mkEnableOption "CMake treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
package = mkGrammarOption pkgs "cmake";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable = mkEnableOption "CMake LSP support" // {default = config.vim.lsp.enable;};
|
||||||
|
servers = mkOption {
|
||||||
|
type = listOf (enum (attrNames servers));
|
||||||
|
default = defaultServers;
|
||||||
|
description = "CMake LSP servers to use";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
format = {
|
||||||
|
enable = mkEnableOption "CMake formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
description = "CMake formatter to use";
|
||||||
|
type = enum (attrNames formats);
|
||||||
|
default = defaultFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
description = "CMake formatter package";
|
||||||
|
type = package;
|
||||||
|
default = formats.${cfg.format.type}.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.lsp.servers =
|
||||||
|
mapListToAttrs (n: {
|
||||||
|
name = n;
|
||||||
|
value = servers.${n};
|
||||||
|
})
|
||||||
|
cfg.lsp.servers;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.format.enable {
|
||||||
|
vim.formatter.conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
setupOpts.formatters_by_ft.cmake = [cfg.format.type];
|
||||||
|
setupOpts.formatters.${cfg.format.type} = {
|
||||||
|
command = getExe cfg.format.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ in {
|
||||||
./dart.nix
|
./dart.nix
|
||||||
./clang.nix
|
./clang.nix
|
||||||
./clojure.nix
|
./clojure.nix
|
||||||
|
./cmake.nix
|
||||||
./css.nix
|
./css.nix
|
||||||
./elixir.nix
|
./elixir.nix
|
||||||
./fsharp.nix
|
./fsharp.nix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue