From cb7ff874e2199ba8a4f87cbaa39bdff0d4d28484 Mon Sep 17 00:00:00 2001 From: raf Date: Mon, 16 Sep 2024 13:28:33 +0300 Subject: [PATCH] languages/python: add basedpyright & python-lsp-server (#372) * languages/python: add basedpyright LSP * languages/python: make basedpyright the default language server * languages/python: add python-lsp-server * docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 8 ++++++- modules/plugins/languages/python.nix | 35 ++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 7c99a971..ce5d8bdf 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -95,7 +95,6 @@ configuration formats. plugin's options can now be found under `indentBlankline.setupOpts`, the previous iteration of the module also included out of place/broken options, which have been removed for the time being. These are: - - `listChar` - this was already unused - `fillChar` - this had nothing to do with the plugin, please configure it yourself by adding `vim.opt.listchars:append({ space = '' })` to your @@ -157,6 +156,7 @@ configuration formats. - Add `vim.ui.breadcrumbs.lualine` to allow fine-tuning breadcrumbs behaviour on Lualine. Only `vim.ui.breadcrumbs.lualine.winbar` is supported for the time being. + - [](#opt-vim.ui.breadcrumbs.lualine.winbar.enable) has been added to allow controlling the default behaviour of the `nvim-navic` component on Lualine, which used to occupy `winbar.lualine_c` as long as breadcrumbs are enabled. @@ -164,6 +164,12 @@ configuration formats. [](#opt-vim.ui.breadcrumbs.lualine.winbar.alwaysRender) to be conform to the new format. +- Add [basedpyright](https://github.com/detachhead/basedpyright) as a Python LSP + server and make it default. + +- Add [python-lsp-server](https://github.com/python-lsp/python-lsp-server) as an + additional Python LSP server. + [ppenguin](https://github.com/ppenguin): - Telescope: diff --git a/modules/plugins/languages/python.nix b/modules/plugins/languages/python.nix index a113a6c6..61aedcee 100644 --- a/modules/plugins/languages/python.nix +++ b/modules/plugins/languages/python.nix @@ -14,7 +14,7 @@ cfg = config.vim.languages.python; - defaultServer = "pyright"; + defaultServer = "basedpyright"; servers = { pyright = { package = pkgs.pyright; @@ -30,6 +30,36 @@ } ''; }; + + basedpyright = { + package = pkgs.basedpyright; + lspConfig = '' + lspconfig.basedpyright.setup{ + capabilities = capabilities; + on_attach = default_on_attach; + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/basedpyright-langserver", "--stdio"}'' + } + } + ''; + }; + + python-lsp-server = { + package = pkgs.python-lsp-server; + lspConfig = '' + lspconfig.pylsp.setup{ + capabilities = capabilities; + on_attach = default_on_attach; + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/pylsp"}'' + } + } + ''; + }; }; defaultFormat = "black"; @@ -61,11 +91,12 @@ black-and-isort = { package = pkgs.writeShellApplication { name = "black"; + runtimeInputs = [pkgs.black pkgs.isort]; text = '' black --quiet - "$@" | isort --profile black - ''; - runtimeInputs = [pkgs.black pkgs.isort]; }; + nullConfig = '' table.insert( ls_sources,