From 6a5d2b9358dbee155cc29f12584e29440fd9a81c Mon Sep 17 00:00:00 2001 From: htran Date: Wed, 4 Oct 2023 00:00:02 -0700 Subject: [PATCH] fix: integrate with pyright, need to use mason to force `pyright` to respect $PATH --- native_configs/neovim/init.lua | 81 ++++++++++++++++--------------- nix/repo/home-profiles/neovim.nix | 29 +++++------ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/native_configs/neovim/init.lua b/native_configs/neovim/init.lua index 32d3caa..da32b33 100644 --- a/native_configs/neovim/init.lua +++ b/native_configs/neovim/init.lua @@ -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('kylechui/nvim-surround') -- surrounds with tags/parenthesis 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 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 [number] for i = 1, 9 do - vim.api.nvim_set_keymap('n', '' .. i, ':tabn ' .. i .. '', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '' .. i, ':tabn ' .. i .. '', + { noremap = true, silent = true, desc = "Jump to tab {idx:" .. i .. "}" }) end -- Show tab number in tab display @@ -804,9 +805,9 @@ local on_attach = function(client, bufnr) require('inlay-hints').on_attach(client, bufnr) end -require("sg").setup { - on_attach = on_attach, -} +-- require("sg").setup { +-- on_attach = on_attach, +-- } -- nvim-cmp local cmp = require 'cmp' @@ -1030,7 +1031,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities() local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'lua_ls', 'cmake', 'tailwindcss', 'prismals', '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({ ui = { @@ -1050,7 +1051,7 @@ require("mason").setup({ require('mason-lspconfig').setup({ -- ensure_installed = servers, ensure_installed = { - "pylsp", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver", + "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver", "ansiblels", "yamlls", "docker_compose_language_service", "jsonls", }, automatic_installation = false, @@ -1111,7 +1112,39 @@ local setup = { on_attach = on_attach, 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({ @@ -1155,37 +1188,6 @@ require('mason-lspconfig').setup_handlers({ }, } 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() require('lspconfig').tsserver.setup { on_attach = on_attach, @@ -1224,6 +1226,7 @@ require('mason-lspconfig').setup_handlers({ setup["nil_ls"]() setup["gopls"]() +setup["pyright"]() require("rust-tools").setup { tools = { -- rust-tools options diff --git a/nix/repo/home-profiles/neovim.nix b/nix/repo/home-profiles/neovim.nix index c256319..c089087 100644 --- a/nix/repo/home-profiles/neovim.nix +++ b/nix/repo/home-profiles/neovim.nix @@ -29,19 +29,16 @@ pkgs.tree-sitter pkgs.fzf # file name 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.stdenv.cc.cc.lib pkgs.nil # oxalica's better nix language server 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 # Language-specific stuffs - pkgs.sumneko-lua-language-server - # pkgs.python3Packages.python-lsp-server - pkgs.nodePackages.pyright pkgs.python3Packages.pylint pkgs.python3Packages.flake8 # FIXME: installing ansible from here just doesn't work :/ @@ -79,8 +76,8 @@ in { package = my_neovim; viAlias = true; vimAlias = true; - withPython3 = true; - withNodeJs = true; + # withPython3 = true; + # withNodeJs = true; # NOTE: this adds path to the wrapped version of neovim extraPackages = nvim_pkgs; extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua"; @@ -143,7 +140,7 @@ in { nvim-colorizer-lua git-worktree-nvim ; - inherit (inputs.cells.dotfiles.packages) sg-nvim; + # inherit (inputs.cells.dotfiles.packages) sg-nvim; in [ plenary-nvim nvim-treesitter.withAllGrammars @@ -189,14 +186,14 @@ in { vim-fugitive nvim-colorizer-lua vim-jack-in - { - plugin = sg-nvim; - # NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API - config = '' - package.cpath = package.cpath .. ";${sg-nvim}/lib/*.so;${sg-nvim}/lib/*.dylib" - ''; - type = "lua"; - } + # { + # plugin = sg-nvim; + # # NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API + # config = '' + # package.cpath = package.cpath .. ";${sg-nvim}/lib/*.so;${sg-nvim}/lib/*.dylib" + # ''; + # type = "lua"; + # } git-worktree-nvim nui-nvim ];