Closed svartkanin closed 3 months ago
I tried it out and could not reproduce. Steps for what I did:
Created minimal config for neovim with lazy:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"mfussenegger/nvim-lint",
config = function()
local lint = require("lint")
lint.linters_by_ft = {
python = { "flake8" },
}
local lint_augroup = vim.api.nvim_create_augroup("nvim_lint_au", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
end,
},
})
Created the same .flake8 and test.py that you have, then:
mkdir flake
cd flake
python -m venv venv
source venv/bin/activate
pip install flake8
pip freeze
#flake8==7.0.0
#mccabe==0.7.0
#pycodestyle==2.11.1
#pyflakes==3.2.0
vim -u conf.lua test.py
And the config file seems to be picked up correctly. Confirmed by seeing the diagnostic when commenting out the ignore in .flake8.
Thanks for the confirmation. I found the culprit, had this in my lsp config
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
which seems to have disabled the loading of the flake8 config.
I'm probably doing something wrong but in my current setup the
.flake8
configuration file doesn't seem to be used when the linter is applied?Example
test.py
which includes tabs.flake8
config filelinter configuration
nvim/lua/plugins/nvim-lint.lua
nvim/after/plugins/nvim-lint.lua
Which will show a flake8 warning
However, running
flake8
manually with$ flake8 test.py
will not show the warning as it locates the
.flake8
configuration inside the folder