From 11d5685aaace42bbaea70dc719e0def7a924619c Mon Sep 17 00:00:00 2001 From: huyjaky Date: Fri, 3 Jan 2025 11:57:45 +0700 Subject: [PATCH] astro-nvim-v3 - fix linter2 --- lazy-lock.json | 2 + lua/plugins/astrolsp.lua | 71 ++++++++++++++++--- lua/plugins/cmp.lua | 41 ++++++----- .../configs/lsp/config/basedpyright.lua | 31 +++++--- lua/plugins/mason.lua | 8 +-- lua/plugins/none-ls.lua | 7 +- lua/plugins/nvimlsp-endhints.lua | 22 ++++++ 7 files changed, 139 insertions(+), 43 deletions(-) create mode 100644 lua/plugins/nvimlsp-endhints.lua diff --git a/lazy-lock.json b/lazy-lock.json index d337b4a..89a095a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -51,6 +51,7 @@ "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "neoconf.nvim": { "branch": "main", "commit": "05d25c121e07c464d6b4203204aa113453eca152" }, "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "6557f20e631d2e9b2a9fd27a5c045d701a3a292c" }, "none-ls.nvim": { "branch": "main", "commit": "c279e541f73a2deea9deb5231b9c037678dd6353" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, @@ -59,6 +60,7 @@ "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-highlight-colors": { "branch": "main", "commit": "68a4df620cf58e2c7336e53738e8cf3a522ad694" }, + "nvim-lsp-endhints": { "branch": "main", "commit": "a449f2f27b6b985ff216964572224ce432d94a86" }, "nvim-lspconfig": { "branch": "master", "commit": "5a812abc65d529ea7673059a348814c21d7f87ff" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-notify": { "branch": "master", "commit": "29b33efc802a304b1cf13ab200915d4e9e67373d" }, diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index c2d5b9e..762c38b 100644 --- a/lua/plugins/astrolsp.lua +++ b/lua/plugins/astrolsp.lua @@ -11,7 +11,7 @@ return { features = { autoformat = false, -- enable or disable auto formatting on start codelens = false, -- enable/disable codelens refresh on start - inlay_hints = true, -- enable/disable inlay hints on start + inlay_hints = false, -- enable/disable inlay hints on start semantic_tokens = true, -- enable/disable semantic token highlighting }, -- customize lsp formatting options @@ -23,23 +23,76 @@ return { config = { -- clangd = require "plugins.configs.lsp.config.clangd", basedpyright = require "plugins.configs.lsp.config.basedpyright", - + jedi_language_server = { init_options = { completion = { - disableSnippets = true, + -- disableSnippets = true, }, - -- diagnostics = { - -- enable = fa, - -- } + + diagnostics = { + enable = false, + } }, }, ruff = { init_options = { settings = { - args = { - "--extend-select=W,COM,ICN", - "--ignore=E501,E722,COM812", + lint = { + select = { + "ALL", + }, + ignore = { + "ANN", + "COM", + "C90", + "DJ", + "EXE", + "T10", + "TID", + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D200", + "D205", + "D212", + "D400", + "D401", + "D415", + "E402", + "E501", + "TRY003", + "TD002", + "TD003", + "FIX002", + "N803", + "PD901" + }, + fixable = { "ALL" }, + }, + + args = {}, + }, + }, + }, + pylsp = { + settings = { + pylsp = { + plugins = { + pyflakes = { enabled = false }, + pycodestyle = { enabled = false }, + autopep8 = { enabled = false }, + yapf = { enabled = false }, + mccabe = { enabled = false }, + -- pylint = { enabled = false }, + pylsp_mypy = { enabled = false }, + pylsp_black = { enabled = false }, + pylsp_isort = { enabled = false }, }, }, }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 777e009..33193ba 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -16,6 +16,29 @@ return { return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil end + cmp.setup.filetype("python", { + sources = cmp.config.sources { + { + name = "nvim_lsp", + entry_filter = function(entry, ctx) + local kind = cmp.get_registered_sources() + + -- if kind.sources == 'jedi_language_server' then return true end return false + for _, source in ipairs(kind) do + -- Kiểm tra nếu nguồn là 'jedi_language_server' + if source.name == "nvim_lsp" and source.source.client.name == "jedi_language_server" then + return true + end + end + + return false + end, + }, + { name = "buffer", priority = 500 }, + { name = "path", priority = 250 }, + }, + }) + return require("astrocore").extend_tbl(opts, { -- Configure window style window = { @@ -74,22 +97,4 @@ return { }) end, }, - -- { - -- "neovim/nvim-lspconfig", - -- opts = function(_, opts) - -- local lspconfig = require "lspconfig" - - -- -- Setup `jedi-language-server` for Python files - -- lspconfig.jedi_language_server.setup { - -- on_attach = opts.on_attach, - -- capabilities = opts.capabilities, - -- filetypes = { "python" }, - -- } - - -- -- Optionally, you can disable pyright - -- lspconfig.pyright.setup { - -- filetypes = {}, - -- } - -- end, - -- }, } diff --git a/lua/plugins/configs/lsp/config/basedpyright.lua b/lua/plugins/configs/lsp/config/basedpyright.lua index 1f256fb..5155059 100644 --- a/lua/plugins/configs/lsp/config/basedpyright.lua +++ b/lua/plugins/configs/lsp/config/basedpyright.lua @@ -6,28 +6,37 @@ return { end, settings = { basedpyright = { - pyright = {enabled = false}, + analysis = { -- diagnosticMode = "workspace", diagnosticMode = "openFilesOnly", - typeCheckingMode = "basic", + typeCheckingMode = "off", autoImportCompletions = false, - autoSearchPath = true, + autoSearchPath = false, + logLevel = "error", + indexing = true, inlayHints = { variableTypes = true, functionReturnTypes = true, callArgumentNames = true, pytestParameters = true, }, - useLibraryCodeForTypes = true, + useLibraryCodeForTypes = false, + strictListInference = true, + strictDictionaryInference = true, + deprecateTypingAliases = false, + enableReachabilityAnalysis = false, + diagnosticSeverityOverrides = { - reportUnusedImport = "information", - reportUnusedFunction = "information", - reportUnusedVariable = "information", - -- reportGeneralTypeIssues = "none", - -- reportOptionalMemberAccess = "none", - -- reportOptionalSubscript = "none", - -- reportPrivateImportUsage = "none", + reportUnusedImport = "none", + reportUnusedFunction = "none", + reportUnusedVariable = "none", + reportGeneralTypeIssues = "none", + reportOptionalMemberAccess = "none", + reportOptionalSubscript = "none", + reportPrivateImportUsage = "none", + reportInvalidStubStatement = "none", + reportIncompleteStub = "none", }, }, }, diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 3bac012..8dc64e3 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -10,9 +10,9 @@ return { -- add more things to the ensure_installed table protecting against community packs modifying it opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "lua_ls", - "jedi_language_server", + -- "jedi_language_server", "ruff", - "basedpyright", + -- "basedpyright", }) end, }, @@ -23,7 +23,7 @@ return { opts = function(_, opts) -- add more things to the ensure_installed table protecting against community packs modifying it opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { - "stylua", + -- "stylua", -- "clang-format", -- "black", -- "prettier", @@ -38,7 +38,7 @@ return { opts = function(_, opts) -- add more things to the ensure_installed table protecting against community packs modifying it opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { - "codelldb", + -- "codelldb", "python", }) end, diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 9882155..0273982 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -3,6 +3,10 @@ ---@type LazySpec return { "nvimtools/none-ls.nvim", + dependencies = { + "nvimtools/none-ls-extras.nvim", + "jay-babu/mason-null-ls.nvim", + }, opts = function(_, opts) -- config variable is the default configuration table for the setup function call local null_ls = require "null-ls" @@ -11,7 +15,8 @@ return { -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics opts.sources = { - -- Set a formatter + require('none-ls.formatting.ruff').with { extra_args = { '--extend-select', 'F' } }, + require 'none-ls.formatting.ruff_format', -- Set a formatter } return opts end, diff --git a/lua/plugins/nvimlsp-endhints.lua b/lua/plugins/nvimlsp-endhints.lua new file mode 100644 index 0000000..122b19e --- /dev/null +++ b/lua/plugins/nvimlsp-endhints.lua @@ -0,0 +1,22 @@ +return { + "chrisgrieser/nvim-lsp-endhints", + event = "LspAttach", + opts = { + icons = { + type = "󰜁 ", + parameter = "󰏪 ", + offspec = " ", -- hint kind not defined in official LSP spec + unknown = " ", -- hint kind is nil + }, + label = { + truncateAtChars = 20, + padding = 1, + marginLeft = 0, + sameKindSeparator = ", ", + }, + extmark = { + priority = 50, + }, + autoEnableHints = true, + }, +}