From 4d38ef5b316ae3b4daa2373b3e159b40c5c6338a Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Thu, 27 Aug 2026 22:05:08 +0200 Subject: [PATCH] feat: python fixes --- init.lua | 4 ++-- lazy-lock.json | 19 ++++++++++--------- lsp/ruff.lua | 10 ++++++++++ lua/config/lsp.lua | 1 + lua/plugins/opts/conformFormat.lua | 18 +++++++++++------- 5 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 lsp/ruff.lua diff --git a/init.lua b/init.lua index e084d70..d8fd174 100644 --- a/init.lua +++ b/init.lua @@ -14,12 +14,12 @@ vim.cmd("set textwidth=0") vim.cmd("set wrapmargin=0") vim.cmd("set linebreak") -- vim.cmd("set colorcolumn=85") -vim.cmd("set conceallevel=0") -- DONT hide characters in MD +-- vim.cmd("set conceallevel=0") -- DONT hide characters in MD vim.cmd("set tabstop=4") vim.cmd("set shiftwidth=4") vim.cmd("set noexpandtab") -- expandtab to use spaces instead of tabs vim.cmd("set wrap") -vim.cmd("set cmdheight=0") -- HACK: hide command line while is not being used, no idea why this works without logic +-- vim.cmd("set cmdheight=0") -- HACK: hide command line while is not being used, no idea why this works without logic vim.lsp.inlay_hint.enable(false) vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" diff --git a/lazy-lock.json b/lazy-lock.json index 7298d1f..0b79cdb 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,15 +1,15 @@ { "aerial.nvim": { "branch": "master", "commit": "28fe6e822ae344544c379d60fcb13c9519a1f08a" }, - "auto-session": { "branch": "main", "commit": "6cde3874a9283c2db55627acca5f28e4fa402320" }, + "auto-session": { "branch": "main", "commit": "c8e6139a2e52a38101fecaba6014d7dd75489044" }, "autoclose.nvim": { "branch": "main", "commit": "27063904b2238ce7867e430885b6abcfb08357ea" }, "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, "blueprints": { "branch": "main", "commit": "e5825c30464f98e77e8b5ffb88d59fd98df6c802" }, - "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, - "flash.nvim": { "branch": "main", "commit": "b6346946d10d07998efee029fb0f7a593806d0cd" }, + "conform.nvim": { "branch": "master", "commit": "016802de402556da54c36bd7359b441266b01cdd" }, + "flash.nvim": { "branch": "main", "commit": "5f0f270fdc7c5b0c21d903ee85b9cb06f2ac636a" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "31d6fb2d618bca1482b9f274751ead5f03461408" }, - "grug-far.nvim": { "branch": "main", "commit": "6e05398cf6cad05b3fb46569db96b1ccfcbbd402" }, + "gitsigns.nvim": { "branch": "main", "commit": "5be654f2232c10ddcad19c1607a67b6b4b78fc29" }, + "grug-far.nvim": { "branch": "main", "commit": "11595bf747edc270bce2069d1020502ad4ae56cf" }, "gruvbox.nvim": { "branch": "main", "commit": "154eb5ff5b96d0641307113fa385eaf0d36d9796" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "komau.vim": { "branch": "master", "commit": "f7c7a00c0cbb67ed269b565a4ada47d96dce14f3" }, @@ -18,11 +18,12 @@ "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "mini.clue": { "branch": "main", "commit": "4d506660e7030a15748ab073bebfe3ed03884000" }, "mini.icons": { "branch": "main", "commit": "98faae31e9be1cc054ae63485e58ceb185efcad0" }, - "neo-tree.nvim": { "branch": "main", "commit": "6679b9395526b52ddb2b137fcd5255dab71c5a58" }, + "neo-tree.nvim": { "branch": "main", "commit": "3352e998cb8343a4b8d82eca50c74aa17bc61f5e" }, "no-neck-pain.nvim": { "branch": "main", "commit": "434fed70b1ee553f8f27e6da7b3899f71b3c6f99" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, + "nui.nvim": { "branch": "main", "commit": "10fc361835c856ba4233ef5ea135b919bf3dce97" }, "nvim-colorizer.lua": { "branch": "master", "commit": "72a05f62c52241bc7441c820eb53946f92b2e6a4" }, - "nvim-lint": { "branch": "master", "commit": "a219b2c9e5b4765e5c845aba119dad55806fcaf1" }, + "nvim-lint": { "branch": "master", "commit": "3d55c8f67c6ae5c15e1042571e107c7a3d5c5f4e" }, "nvim-scrollbar": { "branch": "main", "commit": "f8e87b96cd6362ef8579be456afee3b38fd7e2a8" }, "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, "nvim-treesitter-context": { "branch": "master", "commit": "f3061339b8eaf9fda873600bc425b8d2d8502533" }, @@ -36,7 +37,7 @@ "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, "telescope-git-file-history.nvim": { "branch": "master", "commit": "4442114f9257e682e60a8cb6de14cf988e26055c" }, - "telescope.nvim": { "branch": "master", "commit": "427b576c16792edad01a92b89721d923c19ad60f" }, + "telescope.nvim": { "branch": "master", "commit": "40aedd8a68c78a656a10a8d62d80c54af59420fb" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, diff --git a/lsp/ruff.lua b/lsp/ruff.lua new file mode 100644 index 0000000..e9c1971 --- /dev/null +++ b/lsp/ruff.lua @@ -0,0 +1,10 @@ +return { + cmd = { "ruff", "server" }, + filetypes = { "python" }, + root_markers = { "pyproject.toml", "ruff.toml", ".ruff.toml", ".git" }, + init_options = { + settings = { + -- Ruff language server settings go here + }, + }, +} diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index b33c4a9..facd23d 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -12,6 +12,7 @@ vim.lsp.enable("jdtls") vim.lsp.enable("denols") vim.lsp.enable("luals") vim.lsp.enable("pyright") +-- vim.lsp.enable("ruff") vim.lsp.enable("rust_analyzer") vim.lsp.enable("solargraph") vim.lsp.enable("ts_ls") diff --git a/lua/plugins/opts/conformFormat.lua b/lua/plugins/opts/conformFormat.lua index bec77ea..03a94a6 100644 --- a/lua/plugins/opts/conformFormat.lua +++ b/lua/plugins/opts/conformFormat.lua @@ -10,13 +10,14 @@ local config = { typescriptreact = { "biome", "prettierd", "prettier", stop_after_first = true }, css = { "biome", "prettierd", "prettier", stop_after_first = true }, scss = { "biome", "prettierd", "prettier", stop_after_first = true }, - -- python = function(bufnr) - -- if require("conform").get_formatter_info("ruff_format", bufnr).available then - -- return { "ruff_format" } - -- else - -- return { "isort", "black" } - -- end - -- end, + python = { + -- To fix auto-fixable lint errors. + "ruff_fix", + -- To run the Ruff formatter. + "ruff_format", + -- To organize the imports. + "ruff_organize_imports", + }, ["_"] = { "trim_whitespace" }, -- run only on filetypes without formater -- ["*"] = { "trim_whitespace" }, -- run in all filetypes }, @@ -26,6 +27,9 @@ local config = { }, -- Customize formatters formatters = { + ruff = { + prepend_args = { "format" }, + }, shfmt = { prepend_args = { "-i", "2" }, },