Add LSP basedpyright support
dblume

dblume commited on 2025-07-26 22:11:23
Showing 1 changed files, with 21 additions and 2 deletions.


This is the first draft. Changes coming.
... ...
@@ -454,17 +454,36 @@ let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowTo
454 454
 " See https://wiki.dlma.com/neovim#cscope
455 455
 lua << EOF
456 456
 
457
+  vim.keymap.set("n", "<Leader>d", ":lua vim.diagnostic.open_float(0, {scope='line'})<CR>", { desc = "Show diagnostics" })
458
+  vim.keymap.set("n", "gl", ":lua vim.diagnostic.open_float({ border = 'rounded' })<CR>", { desc = "Show diagnostic fixes" })
457 459
   if vim.fn.executable('clangd') == 1 then
458 460
     vim.lsp.config.clangd = {
459 461
       cmd = { 'clangd', '--background-index' },
460 462
       root_markers = { '.git', '.clang-format', '.editorconfig' },
461 463
       filetypes = { 'c', 'cpp' },
462 464
     }
463
-    vim.keymap.set("n", "<Leader>d", ":lua vim.diagnostic.open_float(0, {scope='line'})<CR>", { desc = "Show diagnostics" })
464
-    vim.keymap.set("n", "gl", ":lua vim.diagnostic.open_float({ border = 'rounded' })<CR>", { desc = "Show diagnostic fixes" })
465 465
     vim.lsp.enable({'clangd'})
466 466
   end
467 467
 
468
+  -- python3 -m pip install basedpyright
469
+  if vim.fn.executable('basedpyright') == 1 then
470
+    vim.lsp.config.basedpyright = {
471
+      cmd = { 'basedpyright-langserver', '--stdio', },
472
+      root_markers = { '.git', 'pyproject.toml', 'setup.py', 'requirements.txt' },
473
+      filetypes = { 'python' },
474
+      settings = {
475
+        basedpyright = {
476
+          analysis = {
477
+            typeCheckingMode = 'basic',
478
+            autoSearchPaths = true,
479
+            useLibraryCodeForTypes = true,
480
+          },
481
+        },
482
+      },
483
+    }
484
+    vim.lsp.enable({'basedpyright'})
485
+  end
486
+
468 487
   require('cscope_maps').setup({ 
469 488
     disable_maps = true, -- Mapping C-] to :Cstag <cword> worse than :tag <cword>
470 489
   -- Alternatively, if we liked the mappings, then customise these two:
471 490