mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
Merge pull request #198 from Donnerinoern/language/markdown
Language/markdown: Added LSP and fixed Glow not working
This commit is contained in:
commit
f2c8413407
3 changed files with 83 additions and 11 deletions
|
@ -25,3 +25,7 @@ Release notes for release 0.6
|
||||||
[donnerinoern](https://github.com/donnerinoern):
|
[donnerinoern](https://github.com/donnerinoern):
|
||||||
|
|
||||||
- Added Gruvbox theme
|
- Added Gruvbox theme
|
||||||
|
|
||||||
|
- Added marksman LSP for Markdown
|
||||||
|
|
||||||
|
- Fixed Markdown-previewer Glow not working and added an option for changing the preview keybind
|
||||||
|
|
|
@ -4,9 +4,29 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) nvim mkIf mkMerge;
|
inherit (lib) nvim mkIf mkMerge mkBinding isList;
|
||||||
|
|
||||||
cfg = config.vim.languages.markdown;
|
cfg = config.vim.languages.markdown;
|
||||||
|
self = import ./markdown.nix {
|
||||||
|
inherit lib config pkgs;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.languages.markdown.glow.mappings;
|
||||||
|
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 {
|
in {
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
|
@ -18,13 +38,21 @@ in {
|
||||||
(mkIf cfg.glow.enable {
|
(mkIf cfg.glow.enable {
|
||||||
vim.startPlugins = ["glow-nvim"];
|
vim.startPlugins = ["glow-nvim"];
|
||||||
|
|
||||||
vim.globals = {
|
vim.maps.normal = mkMerge [
|
||||||
"glow_binary_path" = "${pkgs.glow}/bin";
|
(mkBinding cfg.glow.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.configRC.glow = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
|
||||||
autocmd FileType markdown noremap <leader>p :Glow<CR>
|
require('glow').setup({
|
||||||
|
glow_path = "${pkgs.glow}/bin/glow"
|
||||||
|
});
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.lsp.enable {
|
||||||
|
vim.lsp.lspconfig.enable = true;
|
||||||
|
|
||||||
|
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,41 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkEnableOption mkOption types nvim;
|
inherit (builtins) attrNames;
|
||||||
|
inherit (lib) mkEnableOption mkMappingOption mkOption types nvim isList;
|
||||||
|
|
||||||
cfg = config.vim.languages.markdown;
|
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 {
|
in {
|
||||||
options.vim.languages.markdown = {
|
options.vim.languages.markdown = {
|
||||||
enable = mkEnableOption "Markdown markup language support";
|
enable = mkEnableOption "Markdown markup language support";
|
||||||
|
|
||||||
glow.enable = mkOption {
|
glow = {
|
||||||
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Enable markdown preview in neovim with glow";
|
description = "Enable markdown preview in neovim with glow";
|
||||||
};
|
};
|
||||||
|
mappings = {
|
||||||
|
openPreview = mkMappingOption "Open preview" "<leader>p";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
@ -26,5 +49,22 @@ in {
|
||||||
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
|
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
|
||||||
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue