From 356aac91db2e389350eeafc04b70e844df2176e0 Mon Sep 17 00:00:00 2001 From: kyasuda Date: Fri, 19 Sep 2025 11:42:29 -0700 Subject: [PATCH] fix ruff config and linting --- .config/nvim/lua/core/keymaps.lua | 4 ++-- .../plugins/better-diagnostic-virtual-text.lua | 4 ++-- .config/nvim/lua/plugins/lspconfig.lua | 11 +++-------- .config/nvim/lua/plugins/nvim-lint.lua | 15 +++------------ .config/nvim/lua/utils/ruff.toml | 6 +++--- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index a9e89f7..deb1735 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -396,8 +396,8 @@ local telescope_mappings = { -- {{{ File Explorer Mappings (i guess) local file_explorer_mappings = { { mode = "n", key = "nt", cmd = ":NvimTreeToggle" }, - { mode = "n", key = "nc", cmd = ":lua require('notify').dismiss()" }, - { mode = "n", key = "D", cmd = ":Dotenv .env", group = "Dotenv" }, + { mode = "n", key = "nc", cmd = ":lua Snacks.notifier.hide()" }, + { mode = "n", key = "nh", cmd = ":lua Snacks.notifier.show_history()" }, } -- }}} diff --git a/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua b/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua index 0238391..3bc1814 100644 --- a/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua +++ b/.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua @@ -1,6 +1,6 @@ return { "sontungexpt/better-diagnostic-virtual-text", - event = "LspAttach", + -- event = "LspAttach", enabled = true, config = function() local diagnostic = require("better-diagnostic-virtual-text") @@ -130,7 +130,7 @@ return { down_arrow = "  ", above = false, -- the virtual text will be displayed above the line }, - priority = 2003, -- the priority of virtual text + priority = 10000, -- the priority of virtual text inline = true, }) end, diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 63a4efa..ee2ca37 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -69,7 +69,6 @@ return { end end, }) - vim.lsp.enable(lsp) elseif lsp == "basedpyright" then vim.lsp.config(lsp, { capabilities = capabilities, @@ -97,7 +96,6 @@ return { }, }, }) - vim.lsp.enable(lsp) elseif lsp == "ruff" then vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }), @@ -114,15 +112,12 @@ return { desc = "LSP: Disable hover capability from Ruff", }) vim.lsp.config(lsp, { - capabilities = capabilities, - init_options = { - settings = { - configuration = vim.fn.stdpath("config") .. "lua/utils/ruff.toml", - }, + settings = { + configuration = vim.fn.stdpath("config") .. "/lua/utils/ruff.toml", + logLevel = "info", }, }) end - vim.lsp.config(lsp, { capabilities = capabilities }) vim.lsp.enable(lsp) end end, diff --git a/.config/nvim/lua/plugins/nvim-lint.lua b/.config/nvim/lua/plugins/nvim-lint.lua index 2702189..47bf992 100644 --- a/.config/nvim/lua/plugins/nvim-lint.lua +++ b/.config/nvim/lua/plugins/nvim-lint.lua @@ -25,22 +25,13 @@ return { local orig_try_lint = lint.try_lint lint.try_lint = function(...) - local bufnr = vim.api.nvim_get_current_buf() - local buftype = vim.api.nvim_get_option_value("buftype", { buf = bufnr }) - - -- Skip linting for non-file buffers (like hover docs) - if buftype ~= "" then + local opts = select(2, ...) + local bufnr = (type(opts) == "table" and opts.bufnr) or vim.api.nvim_get_current_buf() + if vim.api.nvim_get_option_value("buftype", { buf = bufnr }) ~= "" then return end - return orig_try_lint(...) end - - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - callback = function() - lint.try_lint() - end, - }) end, event = { "BufReadPre", "BufNewFile" }, } diff --git a/.config/nvim/lua/utils/ruff.toml b/.config/nvim/lua/utils/ruff.toml index 3924c9f..9bfab63 100644 --- a/.config/nvim/lua/utils/ruff.toml +++ b/.config/nvim/lua/utils/ruff.toml @@ -35,6 +35,8 @@ indent-width = 4 # Assume Python 3.9 target-version = "py39" +respect-gitignore = true + [lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. # Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or @@ -57,7 +59,7 @@ convention = "numpy" # Accepts: "google", "numpy", or "pep257". quote-style = "double" # Like Black, indent with spaces, rather than tabs. -indent-style = "spaces" +indent-style = "space" # Like Black, respect magic trailing commas. skip-magic-trailing-comma = false @@ -78,5 +80,3 @@ docstring-code-format = true # This only has an effect when the `docstring-code-format` setting is # enabled. docstring-code-line-length = "dynamic" - -respect-gitignore = true