Skip to content

Commit

Permalink
languages/markdown: added marksman LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnerinoern committed Jan 18, 2024
1 parent 4ded86d commit 75d553b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes/rl-0.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Release notes for release 0.6
[donnerinoern](https://github.com/donnerinoern):

- Added Gruvbox theme

- Added marksman LSP for Markdown
24 changes: 23 additions & 1 deletion modules/languages/markdown/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@
lib,
...
}: let
inherit (lib) nvim mkIf mkMerge;
inherit (lib) nvim mkIf mkMerge isList;

cfg = config.vim.languages.markdown;
servers = {
marksman = {
package = pkgs.marksman;
lspConfig = ''
lspconfig.marksman.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
};
};
in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
Expand All @@ -26,5 +42,11 @@ in {
autocmd FileType markdown noremap <leader>p :Glow<CR>
'';
})

(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;

vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}
37 changes: 36 additions & 1 deletion modules/languages/markdown/markdown.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types nvim;
inherit (builtins) attrNames;
inherit (lib) mkEnableOption mkOption types nvim isList;

cfg = config.vim.languages.markdown;
defaultServer = "marksman";
servers = {
marksman = {
package = pkgs.marksman;
lspConfig = ''
lspconfig.marksman.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
};
};
in {
options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support";
Expand All @@ -26,5 +44,22 @@ in {
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
};

lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};

server = mkOption {
description = "Markdown LSP server to use";
type = with types; enum (attrNames servers);
default = defaultServer;
};

package = mkOption {
description = "Markdown LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = with types; either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
}

0 comments on commit 75d553b

Please sign in to comment.