mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-05 02:53:38 -08:00
fix ruff config and linting
This commit is contained in:
@@ -396,8 +396,8 @@ local telescope_mappings = {
|
|||||||
-- {{{ File Explorer Mappings (i guess)
|
-- {{{ File Explorer Mappings (i guess)
|
||||||
local file_explorer_mappings = {
|
local file_explorer_mappings = {
|
||||||
{ mode = "n", key = "<leader>nt", cmd = ":NvimTreeToggle<CR>" },
|
{ mode = "n", key = "<leader>nt", cmd = ":NvimTreeToggle<CR>" },
|
||||||
{ mode = "n", key = "<leader>nc", cmd = ":lua require('notify').dismiss()<CR>" },
|
{ mode = "n", key = "<leader>nc", cmd = ":lua Snacks.notifier.hide()<CR>" },
|
||||||
{ mode = "n", key = "<leader>D", cmd = ":Dotenv .env<CR>", group = "Dotenv" },
|
{ mode = "n", key = "<leader>nh", cmd = ":lua Snacks.notifier.show_history()<CR>" },
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
"sontungexpt/better-diagnostic-virtual-text",
|
"sontungexpt/better-diagnostic-virtual-text",
|
||||||
event = "LspAttach",
|
-- event = "LspAttach",
|
||||||
enabled = true,
|
enabled = true,
|
||||||
config = function()
|
config = function()
|
||||||
local diagnostic = require("better-diagnostic-virtual-text")
|
local diagnostic = require("better-diagnostic-virtual-text")
|
||||||
@@ -130,7 +130,7 @@ return {
|
|||||||
down_arrow = " ",
|
down_arrow = " ",
|
||||||
above = false, -- the virtual text will be displayed above the line
|
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,
|
inline = true,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ return {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.lsp.enable(lsp)
|
|
||||||
elseif lsp == "basedpyright" then
|
elseif lsp == "basedpyright" then
|
||||||
vim.lsp.config(lsp, {
|
vim.lsp.config(lsp, {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
@@ -97,7 +96,6 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
vim.lsp.enable(lsp)
|
|
||||||
elseif lsp == "ruff" then
|
elseif lsp == "ruff" then
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
|
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",
|
desc = "LSP: Disable hover capability from Ruff",
|
||||||
})
|
})
|
||||||
vim.lsp.config(lsp, {
|
vim.lsp.config(lsp, {
|
||||||
capabilities = capabilities,
|
|
||||||
init_options = {
|
|
||||||
settings = {
|
settings = {
|
||||||
configuration = vim.fn.stdpath("config") .. "lua/utils/ruff.toml",
|
configuration = vim.fn.stdpath("config") .. "/lua/utils/ruff.toml",
|
||||||
},
|
logLevel = "info",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.lsp.config(lsp, { capabilities = capabilities })
|
|
||||||
vim.lsp.enable(lsp)
|
vim.lsp.enable(lsp)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -25,22 +25,13 @@ return {
|
|||||||
local orig_try_lint = lint.try_lint
|
local orig_try_lint = lint.try_lint
|
||||||
|
|
||||||
lint.try_lint = function(...)
|
lint.try_lint = function(...)
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local opts = select(2, ...)
|
||||||
local buftype = vim.api.nvim_get_option_value("buftype", { buf = bufnr })
|
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
|
||||||
-- Skip linting for non-file buffers (like hover docs)
|
|
||||||
if buftype ~= "" then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
return orig_try_lint(...)
|
return orig_try_lint(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
|
||||||
callback = function()
|
|
||||||
lint.try_lint()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ indent-width = 4
|
|||||||
# Assume Python 3.9
|
# Assume Python 3.9
|
||||||
target-version = "py39"
|
target-version = "py39"
|
||||||
|
|
||||||
|
respect-gitignore = true
|
||||||
|
|
||||||
[lint]
|
[lint]
|
||||||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
||||||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
||||||
@@ -57,7 +59,7 @@ convention = "numpy" # Accepts: "google", "numpy", or "pep257".
|
|||||||
quote-style = "double"
|
quote-style = "double"
|
||||||
|
|
||||||
# Like Black, indent with spaces, rather than tabs.
|
# Like Black, indent with spaces, rather than tabs.
|
||||||
indent-style = "spaces"
|
indent-style = "space"
|
||||||
|
|
||||||
# Like Black, respect magic trailing commas.
|
# Like Black, respect magic trailing commas.
|
||||||
skip-magic-trailing-comma = false
|
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
|
# This only has an effect when the `docstring-code-format` setting is
|
||||||
# enabled.
|
# enabled.
|
||||||
docstring-code-line-length = "dynamic"
|
docstring-code-line-length = "dynamic"
|
||||||
|
|
||||||
respect-gitignore = true
|
|
||||||
|
|||||||
Reference in New Issue
Block a user