Merge pull request #1438 from snoweuph/feat/json5
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions

language/json: add json5 support
This commit is contained in:
raf 2026-03-06 19:04:53 +03:00 committed by GitHub
commit daf181249b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -48,6 +48,8 @@
- Added [taplo](https://taplo.tamasfe.dev/) as the default formatter and lsp for - Added [taplo](https://taplo.tamasfe.dev/) as the default formatter and lsp for
`languages.toml` so we don't default to AI-Slop. `languages.toml` so we don't default to AI-Slop.
- Added `json5` into `languages.json`. Some options where renamed.
## Changelog {#sec-release-0-9-changelog} ## Changelog {#sec-release-0-9-changelog}
[taylrfnt](https://github.com/taylrfnt) [taylrfnt](https://github.com/taylrfnt)

View file

@ -18,7 +18,7 @@
servers = { servers = {
jsonls = { jsonls = {
cmd = [(getExe' pkgs.vscode-langservers-extracted "vscode-json-language-server") "--stdio"]; cmd = [(getExe' pkgs.vscode-langservers-extracted "vscode-json-language-server") "--stdio"];
filetypes = ["json" "jsonc"]; filetypes = ["json" "jsonc" "json5"];
init_options = {provideFormatter = true;}; init_options = {provideFormatter = true;};
root_markers = [".git"]; root_markers = [".git"];
}; };
@ -39,7 +39,8 @@ in {
treesitter = { treesitter = {
enable = mkEnableOption "JSON treesitter" // {default = config.vim.languages.enableTreesitter;}; enable = mkEnableOption "JSON treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "json"; jsonPackage = mkGrammarOption pkgs "json";
json5Package = mkGrammarOption pkgs "json5";
}; };
lsp = { lsp = {
@ -66,7 +67,10 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {
vim.treesitter.enable = true; vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package]; vim.treesitter.grammars = [
cfg.treesitter.jsonPackage
cfg.treesitter.json5Package
];
}) })
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
@ -83,6 +87,7 @@ in {
enable = true; enable = true;
setupOpts = { setupOpts = {
formatters_by_ft.json = cfg.format.type; formatters_by_ft.json = cfg.format.type;
formatters_by_ft.json5 = cfg.format.type;
formatters = formatters =
mapListToAttrs (name: { mapListToAttrs (name: {
inherit name; inherit name;