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
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

View file

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

View file

@ -74,7 +74,7 @@
(lib.removePrefix (toString ../.))
(lib.removePrefix "/")
(x: {
url = "https://github.com/NotAShelf/nvf/blob/main/${decl}";
url = "https://github.com/NotAShelf/nvf/blob/main/${x}";
name = "<nvf/${x}>";
})
]
@ -100,11 +100,9 @@ in {
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
# `nixosOptionsDoc` is more customizable.
options.json =
pkgs.runCommand "options.json"
{
pkgs.runCommand "options.json" {
meta.description = "List of nvf options in JSON format";
}
''
} ''
mkdir -p $out/{share/doc,nix-support}
cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf
substitute \
@ -117,15 +115,13 @@ in {
# Generate the `man home-configuration.nix` package
manPages =
pkgs.runCommand "nvf-reference-manpage"
{
pkgs.runCommand "nvf-reference-manpage" {
nativeBuildInputs = [
pkgs.buildPackages.installShellFiles
pkgs.nixos-render-docs
];
allowedReferences = ["out"];
}
''
} ''
# Generate manpages.
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
previous iteration of the module also included out of place/broken options,
which have been removed for the time being. These are:
- `listChar` - this was already unused
- `fillChar` - this had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your
@ -191,3 +192,7 @@ everyone.
- Telescope:
- Fixed `project-nvim` command and keybinding
- 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": {
"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": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
@ -52,21 +36,6 @@
"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": {
"locked": {
"lastModified": 1726188505,
@ -129,11 +98,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1726142289,
"narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=",
"lastModified": 1726871744,
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "280db3decab4cbeb22a4599bd472229ab74d25e1",
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github"
},
"original": {
@ -171,22 +140,6 @@
"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": {
"flake": false,
"locked": {
@ -910,11 +863,11 @@
"plugin-neo-tree-nvim": {
"flake": false,
"locked": {
"lastModified": 1713050882,
"narHash": "sha256-cZwOVpdMT0NCtp6Ha592QA2RzKVS6LhXXcjfDBCQ+0k=",
"lastModified": 1726542367,
"narHash": "sha256-Lqt0KJNT9HmpJwZoWChYeVBrDWhscRe8COqVCwgcTwk=",
"owner": "nvim-neo-tree",
"repo": "neo-tree.nvim",
"rev": "22e566aeb075c94f670f34077e05ba95190dfb4a",
"rev": "a77af2e764c5ed4038d27d1c463fa49cd4794e07",
"type": "github"
},
"original": {
@ -1183,11 +1136,11 @@
"plugin-nvim-lspconfig": {
"flake": false,
"locked": {
"lastModified": 1716498901,
"narHash": "sha256-PMMqPDnq4Q8gWeKQ2WPE+pOf1R1G61wJ+bAWkHpQlzE=",
"lastModified": 1727085470,
"narHash": "sha256-IPpUZEMIL7+4mmqQLy9JeT0cW15/SH3Hx8kyksVcqC0=",
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "b972e7154bc94ab4ecdbb38c8edbccac36f83996",
"rev": "dd329912c8d446240584a2dbcd3802af3a19105a",
"type": "github"
},
"original": {
@ -1327,11 +1280,11 @@
"plugin-nvim-treesitter-context": {
"flake": false,
"locked": {
"lastModified": 1716388265,
"narHash": "sha256-EY5Si6t7LXcxOP3ubGAAMd3lgbeaCOCIybSKi1Ucx98=",
"lastModified": 1726947805,
"narHash": "sha256-5oN/vyhSqDqjLEzECj01A7A+Yq7U1H1HXLbzkC1Ljqw=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter-context",
"rev": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683",
"rev": "3d5390c49e3f8fe457b376df2a49aa39d75b7911",
"type": "github"
},
"original": {
@ -1933,8 +1886,7 @@
"plugin-vim-vsnip": "plugin-vim-vsnip",
"plugin-which-key": "plugin-which-key",
"rnix-lsp": "rnix-lsp",
"systems": "systems_2",
"zig": "zig"
"systems": "systems_2"
}
},
"rust-overlay": {
@ -2006,26 +1958,6 @@
"repo": "flake-utils",
"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",

View file

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

View file

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

View file

@ -8,6 +8,7 @@ in {
./css.nix
./elixir.nix
./go.nix
./hcl.nix
./html.nix
./java.nix
./lua.nix
@ -17,6 +18,7 @@ in {
./ocaml.nix
./php.nix
./python.nix
./r.nix
./rust.nix
./sql.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;
defaultServer = "tsserver";
defaultServer = "ts_ls";
servers = {
tsserver = {
ts_ls = {
package = pkgs.typescript-language-server;
lspConfig = ''
lspconfig.tsserver.setup {
lspconfig.ts_ls.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
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
@ -65,6 +83,7 @@
)
'';
};
prettierd = {
package = pkgs.prettierd;
nullConfig = ''
@ -94,6 +113,7 @@
};
};
in {
_file = ./ts.nix;
options.vim.languages.ts = {
enable = mkEnableOption "Typescript/Javascript language support";
@ -190,11 +210,32 @@ in {
};
})
# Extensions
(mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"];
vim.pluginRC.ts-error-translator = entryAnywhere ''
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.
'';
}
];
}
]);
}