From 4fa4219b026eac7e4698c80a23d01ce6d1df0c7c Mon Sep 17 00:00:00 2001 From: Kulvir Singh Date: Wed, 27 Aug 2025 03:11:42 +0530 Subject: [PATCH] python linter lsp setup: : --- .config/btop/btop.conf | 6 +- .config/nvim/lazy-lock.json | 20 +++--- .config/nvim/lua/lilJ/plugins/blink.lua | 5 -- .config/nvim/lua/lilJ/plugins/conform.lua | 5 ++ .config/nvim/lua/lilJ/plugins/lint.lua | 3 +- .config/nvim/lua/lilJ/plugins/lsp.lua | 84 ++++++++--------------- .config/nvim/lua/lilJ/telescope.lua | 15 ---- 7 files changed, 47 insertions(+), 91 deletions(-) diff --git a/.config/btop/btop.conf b/.config/btop/btop.conf index c15b7fb..b7e4256 100644 --- a/.config/btop/btop.conf +++ b/.config/btop/btop.conf @@ -1,4 +1,4 @@ -#? Config file for btop v. 1.4.3 +#? Config file for btop v. 1.4.4 #* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes. #* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes" @@ -144,7 +144,7 @@ background_update = True custom_cpu_name = "" #* Optional filter for shown disks, should be full path of a mountpoint, separate multiple values with whitespace " ". -#* Begin line with "exclude=" to change to exclude filter, otherwise defaults to "most include" filter. Example: disks_filter="exclude=/boot /home/user". +#* Only disks matching the filter will be shown. Prepend exclude= to only show disks not matching the filter. Examples: disk_filter="/boot /home/user", disks_filter="exclude=/boot /home/user" disks_filter = "" #* Show graphs instead of meters for memory values. @@ -196,7 +196,7 @@ net_download = 100 net_upload = 100 #* Use network graphs auto rescaling mode, ignores any values set above and rescales down to 10 Kibibytes at the lowest. -net_auto = True +net_auto = False #* Sync the auto scaling for download and upload to whichever currently has the highest scale. net_sync = True diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index bd10033..c2a03ce 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,25 +1,25 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "SchemaStore.nvim": { "branch": "main", "commit": "9ecd375f7c261f622bd811ecebcddd59bf5e9de2" }, + "SchemaStore.nvim": { "branch": "main", "commit": "8e74c08998fd786239caba373344f4e4601e21fe" }, "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, - "catpuccin": { "branch": "main", "commit": "76a8d0515024cc55d8bd26fc13f1af88faef3ebf" }, - "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, - "fidget.nvim": { "branch": "main", "commit": "c99541aac9a8f806aa344c4b2d80c86deff91fe1" }, - "gitsigns.nvim": { "branch": "main", "commit": "c7d37ca22b461f64e26f8f6701b2586128ed0bef" }, + "catpuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, + "conform.nvim": { "branch": "master", "commit": "a0ab60ed666c56b37fd7ed1847d2ac52f2482ce0" }, + "fidget.nvim": { "branch": "main", "commit": "4d5858bd4c471c895060e1b9f3575f1551184dc5" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "7f0bf635082bb9b7d2b37766054526a6ccafdb85" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1ec4da522fa49dcecee8d190efda273464dd2192" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, - "mini.nvim": { "branch": "main", "commit": "4035ef97407a6661ae9ff913ff980e271a658502" }, - "nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" }, - "nvim-lspconfig": { "branch": "master", "commit": "9141be4c1332afc83bdf1b0278dbb030f75ff8e3" }, + "mini.nvim": { "branch": "main", "commit": "dee23b41ba27bd583f1d19e199738f3bd0236648" }, + "nvim-lint": { "branch": "master", "commit": "ee04d481d4e6089892c2fb2ad8924b1a053591e1" }, + "nvim-lspconfig": { "branch": "master", "commit": "3d97ec4174bcc750d70718ddedabf150536a5891" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, - "nvim-web-devicons": { "branch": "master", "commit": "3362099de3368aa620a8105b19ed04c2053e38c0" }, + "nvim-web-devicons": { "branch": "master", "commit": "4ae47f4fb18e85b80e84b729974fe65483b06aaf" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, diff --git a/.config/nvim/lua/lilJ/plugins/blink.lua b/.config/nvim/lua/lilJ/plugins/blink.lua index b9446a9..2e8a4af 100644 --- a/.config/nvim/lua/lilJ/plugins/blink.lua +++ b/.config/nvim/lua/lilJ/plugins/blink.lua @@ -2,7 +2,6 @@ return { "saghen/blink.cmp", event = "InsertEnter", - -- use a release tag to download pre-built binaries version = "1.*", dependencies = { "folke/lazydev.nvim", @@ -11,7 +10,6 @@ return { ---@module 'blink.cmp' ---@type blink.cmp.Config opts = { - -- See :h blink-cmp-config-keymap for defining your own keymap keymap = { preset = "default" }, appearance = { @@ -32,8 +30,6 @@ return { }, }, - -- Default list of enabled providers defined so that you can extend it - -- elsewhere in your config, without redefining it, due to `opts_extend` sources = { default = { "lsp", "path", "lazydev", "snippets", "buffer" }, providers = { @@ -43,7 +39,6 @@ return { fuzzy = { implementation = "prefer_rust_with_warning" }, - -- Shows a signature help window while you type arguments for a function signature = { enabled = true }, }, opts_extend = { "sources.default" }, diff --git a/.config/nvim/lua/lilJ/plugins/conform.lua b/.config/nvim/lua/lilJ/plugins/conform.lua index c34aa62..8db159b 100644 --- a/.config/nvim/lua/lilJ/plugins/conform.lua +++ b/.config/nvim/lua/lilJ/plugins/conform.lua @@ -25,6 +25,11 @@ return { go = { "gofumpt", "goimports_reviser" }, html = { "prettier" }, lua = { "stylua" }, + python = { + "ruff_fix", + "ruff_format", + "ruff_organize_imports", + }, typescript = { "prettier" }, typescriptreact = { "prettier" }, }, diff --git a/.config/nvim/lua/lilJ/plugins/lint.lua b/.config/nvim/lua/lilJ/plugins/lint.lua index 5513dfe..46c4870 100644 --- a/.config/nvim/lua/lilJ/plugins/lint.lua +++ b/.config/nvim/lua/lilJ/plugins/lint.lua @@ -6,12 +6,11 @@ return { lint.linters_by_ft = { json = { "jsonlint" }, + python = { "ruff" }, -- typescript = { "eslint" }, -- typescriptreact = { "eslint" }, } - -- Create autocommand which carries out the actual linting - -- on the specified events. local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { group = lint_augroup, diff --git a/.config/nvim/lua/lilJ/plugins/lsp.lua b/.config/nvim/lua/lilJ/plugins/lsp.lua index e1a6ba2..8b7a91b 100644 --- a/.config/nvim/lua/lilJ/plugins/lsp.lua +++ b/.config/nvim/lua/lilJ/plugins/lsp.lua @@ -15,10 +15,6 @@ return { }, config = function() - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), callback = function(event) @@ -27,8 +23,6 @@ return { vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) end - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap. map("K", function() vim.lsp.buf.hover {} end, "Hover Documentation") @@ -39,43 +33,21 @@ return { map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. + -- Useful when your language (C) has ways of declaring types without an actual implementation. map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. map("grn", vim.lsp.buf.rename, "[R]e[n]ame") - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. map("gra", vim.lsp.buf.code_action, "[G]oto Code [A]ction", { "n", "x" }) - -- Find references for the word under your cursor. map("grr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") -- This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. map("grt", require("telescope.builtin").lsp_type_definitions, "[G]oto [T]ype Definition") - -- NOTE: commenting this untile I figure out when to use it - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - -- map("gW", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Open Workspace Symbols") - --- - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - -- map("gO", require("telescope.builtin").lsp_document_symbols, "Open Document Symbols") - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) if client @@ -103,22 +75,24 @@ return { end, }) end - - -- NOTE: commenting this untile I figure out when to use it - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- This may be unwanted, since they displace some of your code - -- - -- if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then - -- map("th", function() - -- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - -- end, "[T]oggle Inlay [H]ints") - -- end end, }) - -- Diagnostic Config - -- See :help vim.diagnostic.Opts + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client == nil then + return + end + if client.name == "ruff" then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + end, + desc = "LSP: Disable hover capability from Ruff", + }) + vim.diagnostic.config { severity_sort = true, float = { source = "if_many" }, @@ -146,19 +120,11 @@ return { }, } - -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP specification. -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. local capabilities = require("blink.cmp").get_lsp_capabilities() - -- enable the following language servers - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { gopls = { filetypes = { "go", "gomod", "gowork", "gotmpl" }, @@ -172,21 +138,27 @@ return { }, }, lua_ls = { - -- cmd = {...}, - -- filetypes = { ...}, - -- capabilities = {}, settings = { lua = { completion = { callsnippet = "replace", }, - -- you can toggle below to ignore lua_ls's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, }, }, }, - pylsp = {}, + pyright = { + settings = { + pyright = { + disableOrganizeImports = true, + }, + python = { + analysis = { + ignore = { "*" }, + }, + }, + }, + }, ts_ls = {}, diff --git a/.config/nvim/lua/lilJ/telescope.lua b/.config/nvim/lua/lilJ/telescope.lua index 3f86b76..3243244 100644 --- a/.config/nvim/lua/lilJ/telescope.lua +++ b/.config/nvim/lua/lilJ/telescope.lua @@ -1,21 +1,8 @@ --- Telescope is a fuzzy finder that comes with a lot of different things that --- it can fuzzy find! It's more than just a "file finder", it can search --- many different aspects of Neovim, your workspace, LSP, and more! --- --- Two important keymaps to use while in Telescope are: --- - Insert mode: --- - Normal mode: ? --- --- This opens a window that shows you all of the keymaps for the current --- Telescope picker. This is really useful to discover what Telescope can --- do as well as how to actually do it! - require("telescope").setup { defaults = { file_ignore_patterns = { ".git/", "node%_modules/.*" }, prompt_prefix = "🔭 ", selection_caret = " ", - -- initial_mode = "normal", }, extensions = { @@ -27,7 +14,6 @@ require("telescope").setup { }, } --- Enable Telescope extensions if they are installed pcall(require("telescope").load_extension, "fzf") pcall(require("telescope").load_extension, "ui-select") @@ -46,7 +32,6 @@ vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" } vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) --- Slightly advanced example of overriding default behavior and theme vim.keymap.set("n", "/", function() builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown { winblend = 10,