From 8d284b106cbefa3537b56a22a84d5d239872a50b Mon Sep 17 00:00:00 2001 From: 4o1x5 <4o1x5@4o1x5.dev> Date: Thu, 19 Dec 2024 20:09:56 +0100 Subject: [PATCH] LSP& formatter: Python and markdown stolen from: https://github.com/spector700/Akari --- config/plugins/lang/default.nix | 2 ++ config/plugins/lang/markdown.nix | 61 ++++++++++++++++++++++++++++++++ config/plugins/lang/python.nix | 45 +++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 config/plugins/lang/markdown.nix create mode 100644 config/plugins/lang/python.nix diff --git a/config/plugins/lang/default.nix b/config/plugins/lang/default.nix index 0e9aeaa..700ad47 100644 --- a/config/plugins/lang/default.nix +++ b/config/plugins/lang/default.nix @@ -7,8 +7,10 @@ ./html.nix ./json.nix ./lua.nix + ./markdown.nix ./nix.nix ./protobuf.nix + ./python.nix ./rust.nix ./ts.nix ./yaml.nix diff --git a/config/plugins/lang/markdown.nix b/config/plugins/lang/markdown.nix new file mode 100644 index 0000000..00c44aa --- /dev/null +++ b/config/plugins/lang/markdown.nix @@ -0,0 +1,61 @@ +{ pkgs, helpers, ... }: +{ + extraPackages = with pkgs; [ + marksman + ]; + + plugins = { + clipboard-image = { + enable = true; + clipboardPackage = pkgs.wl-clipboard; + }; + + image = { + enable = helpers.enableExceptInTests; + integrations.markdown = { + clearInInsertMode = true; + onlyRenderImageAtCursor = true; + }; + }; + + markdown-preview = { + enable = true; + }; + + lsp.servers = { + marksman.enable = true; + + ltex = { + enable = true; + filetypes = [ + "markdown" + "text" + ]; + + settings.completionEnabled = true; + + extraOptions = { + checkFrequency = "save"; + language = "en-GB"; + }; + }; + }; + + lint = { + lintersByFt.md = [ "markdownlint-cli2" ]; + linters.markdownlint-cli2.cmd = "${pkgs.markdownlint-cli2}/bin/markdownlint-cli2"; + }; + }; + + keymaps = [ + { + mode = "n"; + key = "m"; + action = "MarkdownPreviewToggle"; + options = { + silent = true; + desc = "Toggle markdown preview"; + }; + } + ]; +} diff --git a/config/plugins/lang/python.nix b/config/plugins/lang/python.nix new file mode 100644 index 0000000..9c8bc6d --- /dev/null +++ b/config/plugins/lang/python.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: +{ + plugins = { + dap.extensions.dap-python.enable = true; + + conform-nvim.settings = { + formatters_by_ft.python = [ + "ruff_format" + "ruff_organize_imports" + ]; + }; + + lint = { + lintersByFt.python = [ "mypy" ]; + linters.mypy = { + cmd = "${pkgs.mypy}/bin/mypy"; + args = [ "--ignore-missing-imports" ]; + }; + }; + + lsp.servers = { + pyright = { + enable = true; + extraOptions.settings = { + # Using Ruff's import organizer + pyright.disableOrganizeImports = true; + python.analysis = { + # Ignore all files for analysis to exclusively use Ruff for linting + ignore.__raw = ''{ '*' }''; + }; + }; + }; + + ruff = { + enable = true; + onAttach.function = '' + if client.name == 'ruff' then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + ''; + }; + }; + }; +}