From e02af1c226cc854da52d4df03d5e1ddc33f98bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Grochowski?= Date: Wed, 9 Oct 2024 11:58:02 +0200 Subject: [PATCH] feat(nvim): add mdx lsp and highlighting --- modules/nvim/plugins/lsp/config.lua | 9 +- modules/nvim/plugins/lsp/default.nix | 1 + modules/nvim/plugins/theme/config.lua | 4 +- modules/nvim/plugins/treesitter/config.lua | 3 + overlays/node-packages/node-env.nix | 225 +- overlays/node-packages/node-packages.json | 1 + overlays/node-packages/node-packages.nix | 2154 +++++++++++++++++++- 7 files changed, 2212 insertions(+), 185 deletions(-) diff --git a/modules/nvim/plugins/lsp/config.lua b/modules/nvim/plugins/lsp/config.lua index 19f4d31..8403ec1 100644 --- a/modules/nvim/plugins/lsp/config.lua +++ b/modules/nvim/plugins/lsp/config.lua @@ -197,6 +197,7 @@ lspconfig.jsonls.setup { }, } lspconfig.yamlls.setup { + capabilities = capabilities, settings = { yaml = { schemaStore = { @@ -207,6 +208,12 @@ lspconfig.yamlls.setup { }, }, } -lspconfig.bashls.setup {} +lspconfig.bashls.setup { + capabilities = capabilities, +} +lspconfig.mdx_analyzer.setup { + capabilities = capabilities, + root_dir = require('lspconfig.util').root_pattern('.git', 'package.json'), +} require('fidget').setup {} diff --git a/modules/nvim/plugins/lsp/default.nix b/modules/nvim/plugins/lsp/default.nix index 953e93b..e08e9df 100644 --- a/modules/nvim/plugins/lsp/default.nix +++ b/modules/nvim/plugins/lsp/default.nix @@ -13,6 +13,7 @@ efm-langserver localNodePackages."@vtsls/language-server" localNodePackages.vscode-langservers-extracted + localNodePackages."@mdx-js/language-server" ltex-ls lua-language-server nil diff --git a/modules/nvim/plugins/theme/config.lua b/modules/nvim/plugins/theme/config.lua index 4b94e5c..d1f0ac5 100644 --- a/modules/nvim/plugins/theme/config.lua +++ b/modules/nvim/plugins/theme/config.lua @@ -2,4 +2,6 @@ local wk = require 'which-key' vim.cmd.colorscheme 'tokyonight-night' -require('render-markdown').setup {} +require('render-markdown').setup { + file_types = { 'markdown', 'markdown.mdx' }, +} diff --git a/modules/nvim/plugins/treesitter/config.lua b/modules/nvim/plugins/treesitter/config.lua index 4d6db73..5299cdf 100644 --- a/modules/nvim/plugins/treesitter/config.lua +++ b/modules/nvim/plugins/treesitter/config.lua @@ -24,3 +24,6 @@ require('treesitter-context').setup { } require('nvim-ts-autotag').setup {} + +vim.filetype.add { extension = { mdx = 'markdown.mdx' } } +vim.treesitter.language.register('markdown', 'markdown.mdx') diff --git a/overlays/node-packages/node-env.nix b/overlays/node-packages/node-env.nix index c8df27c..bc1e366 100644 --- a/overlays/node-packages/node-env.nix +++ b/overlays/node-packages/node-env.nix @@ -1,6 +1,6 @@ # This file originates from node2nix -{ lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript }: +{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}: let # Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master @@ -9,7 +9,7 @@ let python = if nodejs ? python then nodejs.python else python2; # Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise - tarWrapper = runCommand "tarWrapper" { } '' + tarWrapper = runCommand "tarWrapper" {} '' mkdir -p $out/bin cat > $out/bin/tar <