@@ -22,6 +22,23 @@ function M.init_dap()
2222end
2323
2424local me = require (" kide.melspconfig" )
25+
26+ -- see nvim-lspconfig
27+ function M .organize_imports ()
28+ local params = {
29+ command = " pyright.organizeimports" ,
30+ arguments = { vim .uri_from_bufnr (0 ) },
31+ }
32+
33+ local clients = vim .lsp .get_clients ({
34+ bufnr = vim .api .nvim_get_current_buf (),
35+ name = " pyright" ,
36+ })
37+ for _ , client in ipairs (clients ) do
38+ client :request (" workspace/executeCommand" , params , nil , 0 )
39+ end
40+ end
41+
2542M .config = {
2643 name = " pyright" ,
2744 cmd = { " pyright-langserver" , " --stdio" },
@@ -31,12 +48,24 @@ M.config = {
3148 vim .keymap .set (" n" , " <leader>dc" , dap_py .test_class , { desc = " Dap Test Class" , buffer = bufnr })
3249 vim .keymap .set (" n" , " <leader>dm" , dap_py .test_method , { desc = " Dap Test Method" , buffer = bufnr })
3350 vim .keymap .set (" v" , " <leader>ds" , dap_py .debug_selection , { desc = " Dap Debug Selection" , buffer = bufnr })
51+
52+ local create_command = vim .api .nvim_buf_create_user_command
53+ create_command (bufnr , " OR" , M .organize_imports , {
54+ nargs = 0 ,
55+ })
3456 me .on_attach (client , bufnr )
3557 end ,
3658 on_init = me .on_init ,
3759 capabilities = me .capabilities (),
3860 settings = {
39- pyright = {},
61+ python = {
62+ analysis = {
63+ autoSearchPaths = true ,
64+ useLibraryCodeForTypes = true ,
65+ diagnosticMode = " openFilesOnly" ,
66+ },
67+ },
4068 },
4169}
70+
4271return M
0 commit comments