Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/release-notes/rl-0.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,16 @@
[everforest]: https://github.com/sainnhe/everforest
[oil]: https://github.com/stevearc/oil.nvim
[oil-git-status]: https://github.com/refractalize/oil-git-status.nvim
[neocmakelsp]: https://github.com/neocmakelsp/neocmakelsp
[arduino-language-server]: https://github.com/arduino/arduino-language-server
[glsl_analyzer]: https://github.com/nolanderc/glsl_analyzer

- Fix gitsigns null-ls issue.
- Add [everforest] theme support.
- Add [oil-git-status] support to [oil] module.
- Add CMake support with [neocmakelsp].
- Add Arduino support with [arduino-language-server].
- Add GLSL support with [glsl_analyzer].

[Haskex](https://github.com/haskex):

Expand Down
129 changes: 129 additions & 0 deletions modules/plugins/languages/arduino.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.generators) mkLuaInline;
inherit (lib.lists) optionals;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum listOf nullOr package str;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption;

cfg = config.vim.languages.arduino;

defaultServers = ["arduino-language-server"];
servers = {
arduino-language-server = {
enable = true;
cmd =
[
(getExe pkgs.arduino-language-server)
"-clangd"
(
if cfg.lsp.clangdPackage == null
then "clangd"
else getExe' cfg.lsp.clangdPackage "clangd"
)
"-cli"
(
if cfg.lsp.cliPackage == null
then "arduino-cli"
else getExe cfg.lsp.cliPackage
)
"-cli-config"
cfg.lsp.cliConfigPath
"-fqbn"
cfg.lsp.fqbn
]
++ cfg.lsp.extraArgs;
Comment on lines +23 to +43
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd =
[
(getExe pkgs.arduino-language-server)
"-clangd"
(
if cfg.lsp.clangdPackage == null
then "clangd"
else getExe' cfg.lsp.clangdPackage "clangd"
)
"-cli"
(
if cfg.lsp.cliPackage == null
then "arduino-cli"
else getExe cfg.lsp.cliPackage
)
"-cli-config"
cfg.lsp.cliConfigPath
"-fqbn"
cfg.lsp.fqbn
]
++ cfg.lsp.extraArgs;
cmd =
[
(getExe pkgs.arduino-language-server)
"-clangd"
(getExe' pkgs.clang-tools "clangd")
"-cli"
(getExe pkgs.arduino-cli)
"-cli-config"
"$HOME/.arduino15/arduino-cli.yaml"
"-fqbn"
cfg.lsp.fqbn
];

@NotAShelf @Soliprem I need a second opinion, should cfg.lsp.clangdPackage and friends be added here, or should we remove them and let users configure via vim.lsp.servers?

since cfg.lsp.fqbn is required, I think we'll need to keep it regardless if the others get removed

filetypes = ["arduino"];
root_dir =
mkLuaInline
/*
lua
*/
''
function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern("*.ino")(fname))
end
'';
capabilities = {
textDocument = {
semanticTokens = mkLuaInline "vim.NIL";
};
workspace = {
semanticTokens = mkLuaInline "vim.NIL";
};
};
};
};
in {
options.vim.languages.arduino = {
enable = mkEnableOption "Arduino support";

treesitter = {
enable = mkEnableOption "Arduino treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "arduino";
};

lsp = {
enable = mkEnableOption "Arduino LSP support" // {default = config.vim.lsp.enable;};
servers = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServers;
description = "Arduino LSP servers to use";
};

clangdPackage = mkOption {
type = nullOr package;
default = pkgs.clang-tools;
description = "clangd package to be used by the Arduino LSP";
};

cliPackage = mkOption {
type = nullOr package;
default = pkgs.arduino-cli;
description = "arduino-cli package to be used by the Arduino LSP";
};

cliConfigPath = mkOption {
type = str;
default = "$HOME/.arduino15/arduino-cli.yaml";
description = "Path to the arduino-cli config to be used by the Arduino LSP";
};

fqbn = mkOption {
type = str;
description = "Fully Qualified Board Name to be used by the Arduino LSP";
};

extraArgs = mkOption {
type = listOf str;
default = [];
description = "Extra arguments passed to the Arduino LSP";
};
};
};

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;
})
]);
}
96 changes: 96 additions & 0 deletions modules/plugins/languages/cmake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
})
]);
}
3 changes: 3 additions & 0 deletions modules/plugins/languages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
./arduino.nix
./asm.nix
./astro.nix
./bash.nix
./cue.nix
./dart.nix
./clang.nix
./clojure.nix
./cmake.nix
./css.nix
./elixir.nix
./fsharp.nix
./gleam.nix
./glsl.nix
./go.nix
./hcl.nix
./helm.nix
Expand Down
63 changes: 63 additions & 0 deletions modules/plugins/languages/glsl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
config,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum listOf;
inherit (lib.meta) getExe;
inherit (lib.nvim.attrsets) mapListToAttrs;

cfg = config.vim.languages.glsl;

defaultServers = ["glsl_analyzer"];
servers = {
glsl_analyzer = {
enable = true;
cmd = [(getExe pkgs.glsl_analyzer)];
filetypes = ["glsl" "vert" "tesc" "tese" "frag" "geom" "comp"];
root_markers = [".git"];
};
};
in {
options.vim.languages.glsl = {
enable = mkEnableOption "GLSL language support";

treesitter = {
enable = mkEnableOption "GLSL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "glsl";
};

lsp = {
enable = mkEnableOption "GLSL LSP support" // {default = config.vim.lsp.enable;};

servers = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServers;
description = "GLSL LSP server to use";
};
};
};

config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter = {
enable = true;
grammars = [cfg.treesitter.package];
};
})

(mkIf cfg.lsp.enable {
vim.lsp.servers =
mapListToAttrs (n: {
name = n;
value = servers.${n};
})
cfg.lsp.servers;
})
]);
}
Loading