From f6513daf778b01e22f0a1261248c4669e862e724 Mon Sep 17 00:00:00 2001 From: Henrik Bakken Date: Fri, 12 Sep 2025 13:02:23 +0200 Subject: [PATCH] nvim+mypy --- mypy/mypy.ini | 22 +++++----------------- nvim/init.lua | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/mypy/mypy.ini b/mypy/mypy.ini index a3c2734..82087eb 100644 --- a/mypy/mypy.ini +++ b/mypy/mypy.ini @@ -1,18 +1,6 @@ [mypy] -show_error_context = True -show_error_codes = True -show_column_numbers = True -pretty = True -color_output = True - -disallow_untyped_calls = False -disallow_untyped_defs = True -disallow_incomplete_defs = True -disallow_untyped_decorators = True - -# warn_redundant_casts = True -# warn_unused_ignores = True -# warn_unreachable = True -warn_return_any = False -no_implicit_optional = True -strict_optional = True +strict = true +local_partial_types = true +warn_return_any = false +disallow_subclassing_any = false +pretty = true diff --git a/nvim/init.lua b/nvim/init.lua index b399b4c..dc02d8e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -439,8 +439,36 @@ local function makespec_lspconfig() }, }, }) - lspconfig.pyright.setup({ - cmd = { "pyright-langserver", "--stdio", "--threads", "20" }, + lspconfig.pylsp.setup({ + filetypes = { "python" }, + root_dir = function(fname) + local root_files = { + ".git", + "pyproject.toml", + "setup.py", + "setup.cfg", + "requirements.txt", + "Pipfile", + "pyrightconfig.json", + } + return lspconfig.util.root_pattern(unpack(root_files))(fname) + end, + settings = { + pylsp = { + plugins = { + pylsp_mypy = { + enabled = true, + dmypy = true, + }, + pycodestyle = { enabled = false }, + mccabe = { enabled = false }, + }, + }, + }, + -- Other lspconfig options like on_attach, capabilities can be set here + }) + lspconfig.basedpyright.setup({ + cmd = { "basedpyright-langserver", "--stdio", "--threads", "20" }, filetypes = { "python" }, root_dir = function(fname) local root_files = { @@ -460,7 +488,6 @@ local function makespec_lspconfig() -- logLevel = "Trace", autoImportCompletions = false, diagnosticMode = "workspace", - useLibraryCodeForTypes = true, logTypeEvaluationTime = true, typeEvaluationTimeThreshold = 2000, }, @@ -1061,9 +1088,8 @@ local function makespec_snacks() { "ll", function() Snacks.picker.notifications() end, desc = "Notification History" }, -- code { "cS", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" }, - -- replaced by Trouble - -- { "cW", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" }, - -- { "cd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + { "cW", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" }, + { "cd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, -- terminal { "", function() Snacks.terminal.toggle() end, desc = "Snacks Terminal", mode={"n", "t"} }, { "", function() Snacks.terminal.toggle() end, desc = "which_key_ignore", mode={'n', "t"} }, @@ -1153,7 +1179,6 @@ local function makespec_trouble() }, keys = { { "cc", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics" }, - { "cd", "Trouble diagnostics toggle", desc = "Diagnostics" }, { "cr", "Trouble lsp_references toggle", desc = "References" }, { "cs", "Trouble symbols toggle", desc = "Document Symbols" }, { "ca", "Trouble lsp toggle", desc = "LSP references/definitions/..." },