Compare commits

...

11 commits

Author SHA1 Message Date
ppenguin
0e23f4eb85
Merge eb288de4cf into c957b23aaa 2024-09-27 15:35:42 +01:00
Anthony
c957b23aaa
docs: fix dead links in CONTRIBUTING + put PR template in its appropriate location (#384) 2024-09-26 18:07:04 +03:00
Gerg-L
b4c06c71dc
docs: fix declerations (#381)
* docs: fix declerations

* fix: formatting for your baldness
2024-09-26 01:46:47 +03:00
a56a83bd46
flake: bump neo-tree 2024-09-26 00:29:52 +03:00
Soliprem
8e96f0aaa3
R: adding LSP (#378)
* r: implementing lsp

* r: version bump to context fixes treesitter bug

* r: changing treesitter package definition to mkGrammarOption

* added changelog entry

* docs: wording

---------

Co-authored-by: raf <raf@notashelf.dev>
2024-09-24 12:00:31 +00:00
316f25a0f6
docs: minor formatting changes
Gerg I swear to god...
2024-09-24 06:27:06 +03:00
raf
842b45b969
languages/ts: update lspconfig; rename tsserver to ts_ls (#379)
Silence lspconfig, Microsoft naming convention is speaking.
2024-09-24 06:20:56 +03:00
27b3524508
flake: bump nixpkgs 2024-09-24 06:07:44 +03:00
a85ac83182
flake: minor cleanup
- Get rid of Zig input (nixpkgs one is alright.)
- Minor typo fixes
2024-09-24 06:06:28 +03:00
raf
eb288de4cf
Merge branch 'main' into add-hcl-not-terraform 2024-09-20 15:52:42 +00:00
ppenguin
5952e60f0f
add language HCL
Terraform doesn't register hcl and doesn't offer good DX if manually set
for editing e.g. nomad HCL files.

Incl. reformat with alejandra
2024-08-30 16:31:44 +02:00
12 changed files with 226 additions and 103 deletions

View file

@ -16,7 +16,7 @@ If you have any questions regarding those files, feel free to open an issue or [
## Contributing ## Contributing
The contribution process is mostly documented in the [pull request template](.github/pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask. The contribution process is mostly documented in the [pull request template](pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask.
### Guidelines ### Guidelines

View file

@ -59,6 +59,7 @@ isMaximal: {
python.enable = isMaximal; python.enable = isMaximal;
dart.enable = isMaximal; dart.enable = isMaximal;
bash.enable = isMaximal; bash.enable = isMaximal;
r.enable = isMaximal;
tailwind.enable = isMaximal; tailwind.enable = isMaximal;
typst.enable = isMaximal; typst.enable = isMaximal;
clang = { clang = {

View file

@ -74,7 +74,7 @@
(lib.removePrefix (toString ../.)) (lib.removePrefix (toString ../.))
(lib.removePrefix "/") (lib.removePrefix "/")
(x: { (x: {
url = "https://github.com/NotAShelf/nvf/blob/main/${decl}"; url = "https://github.com/NotAShelf/nvf/blob/main/${x}";
name = "<nvf/${x}>"; name = "<nvf/${x}>";
}) })
] ]
@ -100,11 +100,9 @@ in {
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream # TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
# `nixosOptionsDoc` is more customizable. # `nixosOptionsDoc` is more customizable.
options.json = options.json =
pkgs.runCommand "options.json" pkgs.runCommand "options.json" {
{
meta.description = "List of nvf options in JSON format"; meta.description = "List of nvf options in JSON format";
} } ''
''
mkdir -p $out/{share/doc,nix-support} mkdir -p $out/{share/doc,nix-support}
cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf
substitute \ substitute \
@ -117,15 +115,13 @@ in {
# Generate the `man home-configuration.nix` package # Generate the `man home-configuration.nix` package
manPages = manPages =
pkgs.runCommand "nvf-reference-manpage" pkgs.runCommand "nvf-reference-manpage" {
{
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.buildPackages.installShellFiles pkgs.buildPackages.installShellFiles
pkgs.nixos-render-docs pkgs.nixos-render-docs
]; ];
allowedReferences = ["out"]; allowedReferences = ["out"];
} } ''
''
# Generate manpages. # Generate manpages.
mkdir -p $out/share/man/{man5,man1} mkdir -p $out/share/man/{man5,man1}

View file

@ -108,6 +108,7 @@ everyone.
plugin's options can now be found under `indentBlankline.setupOpts`, the plugin's options can now be found under `indentBlankline.setupOpts`, the
previous iteration of the module also included out of place/broken options, previous iteration of the module also included out of place/broken options,
which have been removed for the time being. These are: which have been removed for the time being. These are:
- `listChar` - this was already unused - `listChar` - this was already unused
- `fillChar` - this had nothing to do with the plugin, please configure it - `fillChar` - this had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your
@ -191,3 +192,7 @@ everyone.
- Telescope: - Telescope:
- Fixed `project-nvim` command and keybinding - Fixed `project-nvim` command and keybinding
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`) - Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
[Soliprem](https://github.com/Soliprem)
- Add LSP and Treesitter support for R under `vim.languages.R`.

View file

@ -1,21 +1,5 @@
{ {
"nodes": { "nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
@ -52,21 +36,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"mnw": { "mnw": {
"locked": { "locked": {
"lastModified": 1726188505, "lastModified": 1726188505,
@ -129,11 +98,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1726142289, "lastModified": 1726871744,
"narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=", "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "280db3decab4cbeb22a4599bd472229ab74d25e1", "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -171,22 +140,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1702350026,
"narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9463103069725474698139ab10f17a9d125da859",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nmd": { "nmd": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -910,11 +863,11 @@
"plugin-neo-tree-nvim": { "plugin-neo-tree-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1713050882, "lastModified": 1726542367,
"narHash": "sha256-cZwOVpdMT0NCtp6Ha592QA2RzKVS6LhXXcjfDBCQ+0k=", "narHash": "sha256-Lqt0KJNT9HmpJwZoWChYeVBrDWhscRe8COqVCwgcTwk=",
"owner": "nvim-neo-tree", "owner": "nvim-neo-tree",
"repo": "neo-tree.nvim", "repo": "neo-tree.nvim",
"rev": "22e566aeb075c94f670f34077e05ba95190dfb4a", "rev": "a77af2e764c5ed4038d27d1c463fa49cd4794e07",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1183,11 +1136,11 @@
"plugin-nvim-lspconfig": { "plugin-nvim-lspconfig": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1716498901, "lastModified": 1727085470,
"narHash": "sha256-PMMqPDnq4Q8gWeKQ2WPE+pOf1R1G61wJ+bAWkHpQlzE=", "narHash": "sha256-IPpUZEMIL7+4mmqQLy9JeT0cW15/SH3Hx8kyksVcqC0=",
"owner": "neovim", "owner": "neovim",
"repo": "nvim-lspconfig", "repo": "nvim-lspconfig",
"rev": "b972e7154bc94ab4ecdbb38c8edbccac36f83996", "rev": "dd329912c8d446240584a2dbcd3802af3a19105a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1327,11 +1280,11 @@
"plugin-nvim-treesitter-context": { "plugin-nvim-treesitter-context": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1716388265, "lastModified": 1726947805,
"narHash": "sha256-EY5Si6t7LXcxOP3ubGAAMd3lgbeaCOCIybSKi1Ucx98=", "narHash": "sha256-5oN/vyhSqDqjLEzECj01A7A+Yq7U1H1HXLbzkC1Ljqw=",
"owner": "nvim-treesitter", "owner": "nvim-treesitter",
"repo": "nvim-treesitter-context", "repo": "nvim-treesitter-context",
"rev": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683", "rev": "3d5390c49e3f8fe457b376df2a49aa39d75b7911",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1933,8 +1886,7 @@
"plugin-vim-vsnip": "plugin-vim-vsnip", "plugin-vim-vsnip": "plugin-vim-vsnip",
"plugin-which-key": "plugin-which-key", "plugin-which-key": "plugin-which-key",
"rnix-lsp": "rnix-lsp", "rnix-lsp": "rnix-lsp",
"systems": "systems_2", "systems": "systems_2"
"zig": "zig"
} }
}, },
"rust-overlay": { "rust-overlay": {
@ -2006,26 +1958,6 @@
"repo": "flake-utils", "repo": "flake-utils",
"type": "github" "type": "github"
} }
},
"zig": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1716725305,
"narHash": "sha256-LIz08gALt2wlutGXAEhNroEoIuPV5ePQB8LI4WzXcy8=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "93b02a697561ecd438cfa5779727b5a1c300cb4c",
"type": "github"
},
"original": {
"owner": "mitchellh",
"repo": "zig-overlay",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -90,10 +90,7 @@
flake = false; flake = false;
}; };
# TODO: get zig from the zig overlay instead of nixpkgs # Language servers (use master instead of nixpkgs)
zig.url = "github:mitchellh/zig-overlay";
# Langauge server (use master instead of nixpkgs)
rnix-lsp.url = "github:nix-community/rnix-lsp"; rnix-lsp.url = "github:nix-community/rnix-lsp";
nil = { nil = {
url = "github:oxalica/nil"; url = "github:oxalica/nil";
@ -159,7 +156,7 @@
flake = false; flake = false;
}; };
# language support # Language support
plugin-sqls-nvim = { plugin-sqls-nvim = {
url = "github:nanotee/sqls.nvim"; url = "github:nanotee/sqls.nvim";
flake = false; flake = false;

View file

@ -8,7 +8,7 @@
# The core neovim modules. # The core neovim modules.
# Contains configuration for core neovim features # Contains configuration for core neovim features
# such as spellchecking, mappings, and the init script (init.vim). # such as spellchecking, mappings, and the init script (init.vim).
neovim = map (p: "${./neovim}/${p}") [ neovim = map (p: ./neovim + "/${p}") [
"init" "init"
"mappings" "mappings"
]; ];
@ -16,7 +16,7 @@
# Individual plugin modules, separated by the type of plugin. # Individual plugin modules, separated by the type of plugin.
# While adding a new type, you must make sure your type is # While adding a new type, you must make sure your type is
# included in the list below. # included in the list below.
plugins = map (p: "${./plugins}/${p}") [ plugins = map (p: ./plugins + "/${p}") [
"assistant" "assistant"
"autopairs" "autopairs"
"comments" "comments"
@ -46,7 +46,7 @@
# The neovim wrapper, used to build a wrapped neovim package # The neovim wrapper, used to build a wrapped neovim package
# using the configuration passed in `neovim` and `plugins` modules. # using the configuration passed in `neovim` and `plugins` modules.
wrapper = map (p: "${./wrapper}/${p}") [ wrapper = map (p: ./wrapper + "/${p}") [
"build" "build"
"rc" "rc"
"warnings" "warnings"
@ -54,7 +54,7 @@
# Extra modules, such as deprecation warnings # Extra modules, such as deprecation warnings
# or renames in one place. # or renames in one place.
extra = map (p: "${./extra}/${p}") [ extra = map (p: ./extra + "/${p}") [
"deprecations.nix" "deprecations.nix"
]; ];
in in

View file

@ -8,6 +8,7 @@ in {
./css.nix ./css.nix
./elixir.nix ./elixir.nix
./go.nix ./go.nix
./hcl.nix
./html.nix ./html.nix
./java.nix ./java.nix
./lua.nix ./lua.nix
@ -17,6 +18,7 @@ in {
./ocaml.nix ./ocaml.nix
./php.nix ./php.nix
./python.nix ./python.nix
./r.nix
./rust.nix ./rust.nix
./sql.nix ./sql.nix
./svelte.nix ./svelte.nix

View file

@ -0,0 +1,71 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.hcl;
in {
options.vim.languages.hcl = {
enable = mkEnableOption "HCL support";
treesitter = {
enable = mkEnableOption "HCL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "hcl";
};
lsp = {
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
# TODO: it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
# TODO: formatter, suppied by above or ...
# FIXME: or should we somehow integrate this:
#` https://git.mzte.de/nvim-plugins/null-ls.nvim/commit/e1fb7e2b2e4400835e23b9603a19813be119852b ??
package = mkOption {
description = "HCL ls package (terraform-ls)";
type = package;
default = pkgs.terraform-ls;
};
};
};
config = mkIf cfg.enable (mkMerge [
{
vim.pluginRC.hcl = ''
vim.api.nvim_create_autocmd("FileType", {
pattern = "hcl",
callback = function(opts)
local bo = vim.bo[opts.buf]
bo.tabstop = 2
bo.shiftwidth = 2
bo.softtabstop = 2
end
})
local ft = require('Comment.ft')
ft
.set('hcl', '#%s')
'';
}
(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 = lib.optionalAttrs (! config.vim.languages.terraform.lsp.enable) {
terraform-ls = ''
lspconfig.terraformls.setup {
capabilities = capabilities,
on_attach=default_on_attach,
cmd = {"${cfg.lsp.package}/bin/terraform-ls", "serve"},
}
'';
};
})
]);
}

View file

@ -0,0 +1,78 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.r;
r-with-languageserver = pkgs.rWrapper.override {
packages = with pkgs.rPackages; [languageserver];
};
defaultServer = "r_language_server";
servers = {
r_language_server = {
package = pkgs.writeShellScriptBin "r_lsp" ''
${r-with-languageserver}/bin/R --slave -e "languageserver::run()"
'';
lspConfig = ''
lspconfig.r_language_server.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${lib.getExe cfg.lsp.package}"}''
}
}
'';
};
};
in {
options.vim.languages.r = {
enable = mkEnableOption "R language support";
treesitter = {
enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "r";
};
lsp = {
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "R LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "R LSP server package, or the command to run as a list of strings";
example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]";
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.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -17,12 +17,12 @@
cfg = config.vim.languages.ts; cfg = config.vim.languages.ts;
defaultServer = "tsserver"; defaultServer = "ts_ls";
servers = { servers = {
tsserver = { ts_ls = {
package = pkgs.typescript-language-server; package = pkgs.typescript-language-server;
lspConfig = '' lspConfig = ''
lspconfig.tsserver.setup { lspconfig.ts_ls.setup {
capabilities = capabilities; capabilities = capabilities;
on_attach = attach_keymaps, on_attach = attach_keymaps,
cmd = ${ cmd = ${
@ -49,6 +49,24 @@
} }
''; '';
}; };
# Here for backwards compatibility. Still consider tsserver a valid
# configuration in the enum, but assert if it's set to *properly*
# redirect the user to the correct server.
tsserver = {
package = pkgs.typescript-language-server;
lspConfig = ''
lspconfig.ts_ls.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
}
}
'';
};
}; };
# TODO: specify packages # TODO: specify packages
@ -65,6 +83,7 @@
) )
''; '';
}; };
prettierd = { prettierd = {
package = pkgs.prettierd; package = pkgs.prettierd;
nullConfig = '' nullConfig = ''
@ -94,6 +113,7 @@
}; };
}; };
in { in {
_file = ./ts.nix;
options.vim.languages.ts = { options.vim.languages.ts = {
enable = mkEnableOption "Typescript/Javascript language support"; enable = mkEnableOption "Typescript/Javascript language support";
@ -190,11 +210,32 @@ in {
}; };
}) })
# Extensions
(mkIf cfg.extensions."ts-error-translator".enable { (mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"]; vim.startPlugins = ["ts-error-translator"];
vim.pluginRC.ts-error-translator = entryAnywhere '' vim.pluginRC.ts-error-translator = entryAnywhere ''
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
''; '';
}) })
# Warn the user if they have set the default server name to tsserver to match upstream (us)
# The name "tsserver" has been deprecated in lspconfig, and now should be called ts_ls. This
# is a purely cosmetic change, but emits a warning if not accounted for.
{
assertions = [
{
assertion = cfg.lsp.enable -> cfg.lsp.server != "tsserver";
message = ''
As of a recent lspconfig update, he `tsserver` configuration has been renamed
to `ts_ls` to match upstream behaviour of `lspconfig`, and the name `tsserver`
is no longer considered valid by nvf. Please set `vim.languages.ts.lsp.server`
to `"ts_ls"` instead of to `${cfg.lsp.server}`
Please see <https://github.com/neovim/nvim-lspconfig/pull/3232> for more details
about this change.
'';
}
];
}
]); ]);
} }