mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 23:16:46 +00:00
Compare commits
3 commits
96880fcfdd
...
438ea0939e
Author | SHA1 | Date | |
---|---|---|---|
|
438ea0939e | ||
|
c2780f497b | ||
|
c6453c4e69 |
6 changed files with 140 additions and 14 deletions
|
@ -65,17 +65,14 @@ isMaximal: {
|
||||||
r.enable = isMaximal;
|
r.enable = isMaximal;
|
||||||
tailwind.enable = isMaximal;
|
tailwind.enable = isMaximal;
|
||||||
typst.enable = isMaximal;
|
typst.enable = isMaximal;
|
||||||
clang = {
|
clang.enable = isMaximal;
|
||||||
enable = isMaximal;
|
|
||||||
lsp.server = "clangd";
|
|
||||||
};
|
|
||||||
|
|
||||||
scala.enable = isMaximal;
|
scala.enable = isMaximal;
|
||||||
rust = {
|
rust = {
|
||||||
enable = isMaximal;
|
enable = isMaximal;
|
||||||
crates.enable = isMaximal;
|
crates.enable = isMaximal;
|
||||||
};
|
};
|
||||||
csharp.enable = isMaximal;
|
csharp.enable = isMaximal;
|
||||||
|
julia.enable = isMaximal;
|
||||||
vala.enable = isMaximal;
|
vala.enable = isMaximal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,10 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
|
||||||
- Add C# support under `vim.languages.csharp`, with support for both
|
- Add C# support under `vim.languages.csharp`, with support for both
|
||||||
omnisharp-roslyn and csharp-language-server.
|
omnisharp-roslyn and csharp-language-server.
|
||||||
|
|
||||||
|
- Add Julia support under `vim.languages.julia`. Note that the entirety of Julia
|
||||||
|
is bundled with nvf, if you enable the module, since there is no way to
|
||||||
|
provide only the LSP server.
|
||||||
|
|
||||||
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
|
[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
|
- Make Neovim's configuration file entirely Lua based. This comes with a few
|
||||||
|
|
|
@ -30,6 +30,7 @@ in {
|
||||||
./typst.nix
|
./typst.nix
|
||||||
./zig.nix
|
./zig.nix
|
||||||
./csharp.nix
|
./csharp.nix
|
||||||
|
./julia.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages = {
|
options.vim.languages = {
|
||||||
|
|
126
modules/plugins/languages/julia.nix
Normal file
126
modules/plugins/languages/julia.nix
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) attrNames isList;
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.types) either listOf package str enum bool nullOr;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit (lib.nvim.lua) expToLua;
|
||||||
|
|
||||||
|
defaultServer = "julials";
|
||||||
|
servers = {
|
||||||
|
julials = {
|
||||||
|
package = pkgs.julia.withPackages ["LanguageServer"];
|
||||||
|
internalFormatter = true;
|
||||||
|
lspConfig = ''
|
||||||
|
lspconfig.julials.setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = default_on_attach,
|
||||||
|
cmd = ${
|
||||||
|
if isList cfg.lsp.package
|
||||||
|
then expToLua cfg.lsp.package
|
||||||
|
else ''
|
||||||
|
{
|
||||||
|
"${optionalString (cfg.lsp.package != null) "${cfg.lsp.package}/bin/"}julia",
|
||||||
|
"--startup-file=no",
|
||||||
|
"--history-file=no",
|
||||||
|
"--eval",
|
||||||
|
[[
|
||||||
|
using LanguageServer
|
||||||
|
|
||||||
|
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
|
||||||
|
project_path = let
|
||||||
|
dirname(something(
|
||||||
|
## 1. Finds an explicitly set project (JULIA_PROJECT)
|
||||||
|
Base.load_path_expand((
|
||||||
|
p = get(ENV, "JULIA_PROJECT", nothing);
|
||||||
|
p === nothing ? nothing : isempty(p) ? nothing : p
|
||||||
|
)),
|
||||||
|
## 2. Look for a Project.toml file in the current working directory,
|
||||||
|
## or parent directories, with $HOME as an upper boundary
|
||||||
|
Base.current_project(),
|
||||||
|
## 3. First entry in the load path
|
||||||
|
get(Base.load_path(), 1, nothing),
|
||||||
|
## 4. Fallback to default global environment,
|
||||||
|
## this is more or less unreachable
|
||||||
|
Base.load_path_expand("@v#.#"),
|
||||||
|
))
|
||||||
|
end
|
||||||
|
@info "Running language server" VERSION pwd() project_path depot_path
|
||||||
|
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
|
||||||
|
server.runlinter = true
|
||||||
|
run(server)
|
||||||
|
]]
|
||||||
|
}
|
||||||
|
''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
cfg = config.vim.languages.julia;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
vim.languages.julia = {
|
||||||
|
enable = mkEnableOption "Julia language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = mkEnableOption "Julia treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
package = mkGrammarOption pkgs "julia";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = config.vim.languages.enableLSP;
|
||||||
|
description = ''
|
||||||
|
Whether to enable Julia LSP support.
|
||||||
|
|
||||||
|
::: {.note}
|
||||||
|
The entirety of Julia is bundled with nvf, if you enable this
|
||||||
|
option, since there is no way to provide only the LSP server.
|
||||||
|
|
||||||
|
If you want to avoid that, you have to change
|
||||||
|
[](#opt-vim.languages.julia.lsp.package) to use the Julia binary
|
||||||
|
in {env}`PATH` (set it to `null`), and add the `LanguageServer` package to
|
||||||
|
Julia in your devshells.
|
||||||
|
:::
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
type = enum (attrNames servers);
|
||||||
|
default = defaultServer;
|
||||||
|
description = "Julia LSP server to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
description = ''
|
||||||
|
Julia LSP server package, `null` to use the Julia binary in {env}`PATH`, or
|
||||||
|
the command to run as a list of strings.
|
||||||
|
'';
|
||||||
|
type = nullOr (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.lsp.lspconfig.enable = true;
|
||||||
|
vim.lsp.lspconfig.sources.julia-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
|
@ -20,6 +20,8 @@
|
||||||
servers = {
|
servers = {
|
||||||
vala_ls = {
|
vala_ls = {
|
||||||
package = pkgs.vala-language-server;
|
package = pkgs.vala-language-server;
|
||||||
|
runtimeInputs = pkgs.uncrustify;
|
||||||
|
internalFormatter = true;
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.vala_ls.setup {
|
lspconfig.vala_ls.setup {
|
||||||
capabilities = capabilities;
|
capabilities = capabilities;
|
||||||
|
@ -41,7 +43,7 @@
|
||||||
nullConfig = pkg: ''
|
nullConfig = pkg: ''
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
null_ls.builtins.diagnostics.eslint_d.with({
|
null_ls.builtins.diagnostics.vala_lint.with({
|
||||||
command = "${getExe pkg}",
|
command = "${getExe pkg}",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -54,13 +56,11 @@ in {
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkEnableOption "Vala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
enable = mkEnableOption "Vala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
|
||||||
package = mkGrammarOption pkgs "vala";
|
package = mkGrammarOption pkgs "vala";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
|
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Vala LSP server to use";
|
description = "Vala LSP server to use";
|
||||||
type = enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
|
@ -69,7 +69,7 @@ in {
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Vala LSP server package, or the command to run as a list of strings";
|
description = "Vala LSP server package, or the command to run as a list of strings";
|
||||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
example = ''[lib.getExe pkgs.vala-language-server]'';
|
||||||
type = either package (listOf str);
|
type = either package (listOf str);
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
|
@ -77,7 +77,6 @@ in {
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
enable = mkEnableOption "extra Vala diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
enable = mkEnableOption "extra Vala diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||||
|
|
||||||
types = diagnostics {
|
types = diagnostics {
|
||||||
langDesc = "Vala";
|
langDesc = "Vala";
|
||||||
inherit diagnosticsProviders;
|
inherit diagnosticsProviders;
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) stringLength concatMapStringsSep;
|
inherit (lib.strings) concatMapStringsSep;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
|
|
||||||
cfg = config.vim.utility.preview.markdownPreview;
|
cfg = config.vim.utility.preview.markdownPreview;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -19,8 +18,8 @@ in {
|
||||||
mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
|
mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
|
||||||
mkdp_command_for_global = cfg.alwaysAllowPreview;
|
mkdp_command_for_global = cfg.alwaysAllowPreview;
|
||||||
mkdp_open_to_the_world = cfg.broadcastServer;
|
mkdp_open_to_the_world = cfg.broadcastServer;
|
||||||
mkdp_open_ip = mkIf (stringLength cfg.customIP > 0) cfg.customIP;
|
mkdp_open_ip = cfg.customIP;
|
||||||
mkdp_port = mkIf (stringLength cfg.customPort > 0) cfg.customPort;
|
mkdp_port = cfg.customPort;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue