fix: integrate with pyright, need to use mason to force `pyright` to respect $PATH

bleed
htran 2023-10-04 00:00:02 -07:00
parent 86f1880748
commit 6a5d2b9358
2 changed files with 55 additions and 55 deletions

View File

@ -107,7 +107,7 @@ WPlug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal
WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*)
WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis
WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration
WPlug('tjdevries/sg.nvim') -- Cody and other cool sourcegraph stuffs -- WPlug('tjdevries/sg.nvim') -- Cody and other cool sourcegraph stuffs
-- UI & colorscheme -- UI & colorscheme
WPlug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts WPlug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts
@ -572,7 +572,8 @@ end, { desc = '[F]ind [D]iagnostics' })
-- Jump to specific tab with <C-t>[number] -- Jump to specific tab with <C-t>[number]
for i = 1, 9 do for i = 1, 9 do
vim.api.nvim_set_keymap('n', '<C-t>' .. i, ':tabn ' .. i .. '<CR>', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '<C-t>' .. i, ':tabn ' .. i .. '<CR>',
{ noremap = true, silent = true, desc = "Jump to tab {idx:" .. i .. "}" })
end end
-- Show tab number in tab display -- Show tab number in tab display
@ -804,9 +805,9 @@ local on_attach = function(client, bufnr)
require('inlay-hints').on_attach(client, bufnr) require('inlay-hints').on_attach(client, bufnr)
end end
require("sg").setup { -- require("sg").setup {
on_attach = on_attach, -- on_attach = on_attach,
} -- }
-- nvim-cmp -- nvim-cmp
local cmp = require 'cmp' local cmp = require 'cmp'
@ -1030,7 +1031,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
local servers = { local servers = {
'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'lua_ls', 'cmake', 'tailwindcss', 'prismals', 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'lua_ls', 'cmake', 'tailwindcss', 'prismals',
'nil_ls', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels", 'nil_ls', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels",
"jsonls", "denols", "gopls", "nickel_ls", 'pylsp', "jsonls", "denols", "gopls", "nickel_ls",
} }
require("mason").setup({ require("mason").setup({
ui = { ui = {
@ -1050,7 +1051,7 @@ require("mason").setup({
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
-- ensure_installed = servers, -- ensure_installed = servers,
ensure_installed = { ensure_installed = {
"pylsp", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver",
"ansiblels", "yamlls", "docker_compose_language_service", "jsonls", "ansiblels", "yamlls", "docker_compose_language_service", "jsonls",
}, },
automatic_installation = false, automatic_installation = false,
@ -1111,7 +1112,39 @@ local setup = {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
end end,
["pyright"] = function()
require('lspconfig').pyright.setup {
on_attach = on_attach,
cmd = { "pyright-langserver", "--stdio", },
capabilities = capabilities,
settings = {
pyright = {
disableLanguageServices = false,
disableOrganizeImports = false,
reportShadowedImports = "warning",
},
python = {
analysis = {
autoImportCompletions = true,
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "openFilesOnly",
-- diagnosticSeverityOverrides =
extraPaths = {},
logLevel = "Trace",
-- stubPath = "typings",
typeCheckingMode = "strict",
-- typeshedPaths = {},
venvPath = nil,
},
linting = {
mypyEnabled = true,
}
},
},
}
end,
} }
require('mason-lspconfig').setup_handlers({ require('mason-lspconfig').setup_handlers({
@ -1155,37 +1188,6 @@ require('mason-lspconfig').setup_handlers({
}, },
} }
end, end,
["pyright"] = function()
require('lspconfig').pyright.setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
pyright = {
disableLanguageServices = false,
disableOrganizeImports = false,
},
python = {
analysis = {
autoImportCompletions = true,
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
-- diagnosticSeverityOverrides =
extraPaths = {},
logLevel = "Information",
stubPath = "typings",
typeCheckingMode = "basic",
typeshedPaths = {},
useLibraryCodeForTypes = false,
pythonPath = "python",
venvPath = "",
},
linting = {
mypyEnabled = true,
}
},
},
}
end,
["tsserver"] = function() ["tsserver"] = function()
require('lspconfig').tsserver.setup { require('lspconfig').tsserver.setup {
on_attach = on_attach, on_attach = on_attach,
@ -1224,6 +1226,7 @@ require('mason-lspconfig').setup_handlers({
setup["nil_ls"]() setup["nil_ls"]()
setup["gopls"]() setup["gopls"]()
setup["pyright"]()
require("rust-tools").setup { require("rust-tools").setup {
tools = { tools = {
-- rust-tools options -- rust-tools options

View File

@ -29,19 +29,16 @@
pkgs.tree-sitter pkgs.tree-sitter
pkgs.fzf # file name fuzzy search pkgs.fzf # file name fuzzy search
pkgs.ripgrep # content fuzzy search pkgs.ripgrep # content fuzzy search
pkgs.zk # Zettelkasten (limited support) # pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?) pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib pkgs.stdenv.cc.cc.lib
pkgs.nil # oxalica's better nix language server pkgs.nil # oxalica's better nix language server
inputs.nix-boost.packages."${system}".rust4cargo inputs.nix-boost.packages."${system}".rust4cargo
inputs.sg-nvim.packages.${system}.default # inputs.sg-nvim.packages.${system}.default
pkgs.go # doesn't work, Mason installs from runtime path pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs # Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint pkgs.python3Packages.pylint
pkgs.python3Packages.flake8 pkgs.python3Packages.flake8
# FIXME: installing ansible from here just doesn't work :/ # FIXME: installing ansible from here just doesn't work :/
@ -79,8 +76,8 @@ in {
package = my_neovim; package = my_neovim;
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;
withPython3 = true; # withPython3 = true;
withNodeJs = true; # withNodeJs = true;
# NOTE: this adds path to the wrapped version of neovim # NOTE: this adds path to the wrapped version of neovim
extraPackages = nvim_pkgs; extraPackages = nvim_pkgs;
extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua"; extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua";
@ -143,7 +140,7 @@ in {
nvim-colorizer-lua nvim-colorizer-lua
git-worktree-nvim git-worktree-nvim
; ;
inherit (inputs.cells.dotfiles.packages) sg-nvim; # inherit (inputs.cells.dotfiles.packages) sg-nvim;
in [ in [
plenary-nvim plenary-nvim
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
@ -189,14 +186,14 @@ in {
vim-fugitive vim-fugitive
nvim-colorizer-lua nvim-colorizer-lua
vim-jack-in vim-jack-in
{ # {
plugin = sg-nvim; # plugin = sg-nvim;
# NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API # # NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API
config = '' # config = ''
package.cpath = package.cpath .. ";${sg-nvim}/lib/*.so;${sg-nvim}/lib/*.dylib" # package.cpath = package.cpath .. ";${sg-nvim}/lib/*.so;${sg-nvim}/lib/*.dylib"
''; # '';
type = "lua"; # type = "lua";
} # }
git-worktree-nvim git-worktree-nvim
nui-nvim nui-nvim
]; ];