From b183c9027c26815f749094ce365df0f135f8b787 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sun, 21 Jan 2024 18:47:09 -0300 Subject: [PATCH 01/72] feat(Neovim): Update a keybinding to use current API function The function called in the keybinding is being deprecated. But there has been suggested a new function, that is being used now. --- nvim/lua/lsp/keymaps.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nvim/lua/lsp/keymaps.lua b/nvim/lua/lsp/keymaps.lua index d393ccf..fce70c5 100644 --- a/nvim/lua/lsp/keymaps.lua +++ b/nvim/lua/lsp/keymaps.lua @@ -11,7 +11,9 @@ vim.api.nvim_create_autocmd("LspAttach", { vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set("n", "wl", function() vim.pretty_print(vim.lsp.buf.list_workspace_folders()) end, opts) + vim.keymap.set("n", "wl", function() + vim.print(vim.lsp.buf.list_workspace_folders()) + end, opts) vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) From 6955551138fc90acfbe90b7d60fe3772ead4a0b6 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 22 Jan 2024 11:53:13 -0300 Subject: [PATCH 02/72] feat(Neovim): Update font and window sizes Updated the font and window sizes used in a 15inches 1080p display resolution. --- nvim-gtk/window.toml | 4 ++-- nvim/ginit.vim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nvim-gtk/window.toml b/nvim-gtk/window.toml index 9ded44d..f169efb 100644 --- a/nvim-gtk/window.toml +++ b/nvim-gtk/window.toml @@ -1,5 +1,5 @@ -current_width = 777 -current_height = 1000 +current_width = 782 # for Iosevka Curly Slab 11.5; 96col +current_height = 1044 is_maximized = false show_sidebar = false sidebar_width = 174 diff --git a/nvim/ginit.vim b/nvim/ginit.vim index cc2ca8f..180b81e 100644 --- a/nvim/ginit.vim +++ b/nvim/ginit.vim @@ -1,4 +1,4 @@ -call rpcnotify(1, 'Gui', 'Font', 'Iosevka Curly Slab 8.4') +call rpcnotify(1, 'Gui', 'Font', 'Iosevka Curly Slab 11.5') " Iosevka customizations: Haskell ligations; JetBrains Mono Style variant; " cv-a-single-storey-serifed; cv-g-double-storey-open; " cv-lig-ltgteq-slanted; cv-tilde-high; cv-underscore-low; cv-dollar-open; From 724587d5e56cc26c186013e4dc0037110f90369f Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 22 Jan 2024 15:29:37 -0300 Subject: [PATCH 03/72] feat(Vim): Add some LSP servers to CoC Also reordered the configuration a little bit. --- vim/coc-settings.json | 19 +++++++++++-------- vim/lsp.vim | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/vim/coc-settings.json b/vim/coc-settings.json index 3199aed..0ccc118 100644 --- a/vim/coc-settings.json +++ b/vim/coc-settings.json @@ -40,14 +40,17 @@ "default": "" }, - // coc-diagnostic - "diagnostic-languageserver.filetypes": { - "python": ["flake8", "pylint", "mypy", "pycodestyle"] - }, - "diagnostic-languageserver.linters": { - "pycodestyle": { - "sourceName": "pycodestyle", - "command": "pycodestyle" + "languageserver": { + "haskell": { + "command": "haskell-language-server-wrapper", + "args": ["--lsp"], + "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"], + "filetypes": ["haskell", "lhaskell"], + "settings": { + "haskell": { + "formattingProvider": "formolu" + } + } } } } diff --git a/vim/lsp.vim b/vim/lsp.vim index aa97d9e..39a4316 100644 --- a/vim/lsp.vim +++ b/vim/lsp.vim @@ -1,5 +1,8 @@ " Default extensions -let g:coc_global_extensions = ["coc-diagnostic", "coc-jedi", "coc-clangd"] +let g:coc_global_extensions = [ + \ "coc-diagnostic", + \ "coc-jedi", "@yaegassy/coc-mypy", "coc-clangd", "coc-rust-analyzer" + \ ] " Remap keys for gotos nmap gd (coc-definition) From fff98b3bf57bf080b64f08e6f6f51b0c1895803e Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 22 Jan 2024 15:32:04 -0300 Subject: [PATCH 04/72] feat(Vim): Update diagnostics icons for CoC --- vim/coc-settings.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/coc-settings.json b/vim/coc-settings.json index 0ccc118..61a9fc7 100644 --- a/vim/coc-settings.json +++ b/vim/coc-settings.json @@ -6,10 +6,10 @@ // https://microsoft.github.io/vscode-codicons/dist/codicon.html // Unicode symbols taken from VS Code source code (search symbol- entries): // https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts#L113-L556 - "diagnostic.errorSign": "", - "diagnostic.warningSign": "", - "diagnostic.infoSign": "", - "diagnostic.hintSign": "", + "diagnostic.errorSign": "", + "diagnostic.warningSign": "", + "diagnostic.infoSign": "", + "diagnostic.hintSign": "", "suggest.completionItemKindLabels": { "keyword": "", From 50a61778e7ccddf7c36690eaec1dff3fcca468b6 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 22 Jan 2024 15:56:09 -0300 Subject: [PATCH 05/72] feat(Vim): Change LSP for Python in CoC --- vim/lsp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/lsp.vim b/vim/lsp.vim index 39a4316..f49fbdd 100644 --- a/vim/lsp.vim +++ b/vim/lsp.vim @@ -1,7 +1,7 @@ " Default extensions let g:coc_global_extensions = [ \ "coc-diagnostic", - \ "coc-jedi", "@yaegassy/coc-mypy", "coc-clangd", "coc-rust-analyzer" + \ "@yaegassy/coc-ruff", "@yaegassy/coc-pylsp", "@yaegassy/coc-mypy", "coc-clangd", "coc-rust-analyzer" \ ] " Remap keys for gotos From 49878a0ff4d3cd2e9f4412c56f3aa095336a12a1 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 22 Jan 2024 21:39:45 -0300 Subject: [PATCH 06/72] feat(LSP): Reorder some diagnostics configurations --- nvim/lua/lsp/diagnostics.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/nvim/lua/lsp/diagnostics.lua b/nvim/lua/lsp/diagnostics.lua index ab545b1..77b675f 100644 --- a/nvim/lua/lsp/diagnostics.lua +++ b/nvim/lua/lsp/diagnostics.lua @@ -5,8 +5,12 @@ vim.diagnostic.config({ [vim.diagnostic.severity.WARN] = "", [vim.diagnostic.severity.INFO] = "", [vim.diagnostic.severity.HINT] = "", - } - } + }, + }, + + update_in_insert = true, + virtual_text = { source = "if_many", spacing = 24 }, + float = { source = "if_many", border = "rounded" }, }) vim.api.nvim_create_autocmd("LspAttach", { @@ -21,15 +25,5 @@ vim.api.nvim_create_autocmd("LspAttach", { vim.diagnostic.open_float({ focusable = false, header = "" }) end }) - - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - update_in_insert = true, - virtual_text = { source = "if_many", spacing = 24 }, - } - ) - vim.diagnostic.config({ - float = { source = "if_many", border = "rounded" } - }) end, }) From 76d872d09a5362ad8df7a86b7ad7f2f1627d7718 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 08:16:54 -0300 Subject: [PATCH 07/72] feat(Neovim): Add some fallbacks for pre-release As some parts of the configuration are meant to work on the current pre-release version. To make the settings work on current release version there were added some guards around the experimental code. --- nvim/lua/lsp/diagnostics.lua | 6 ++++++ nvim/lua/lsp/init.lua | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nvim/lua/lsp/diagnostics.lua b/nvim/lua/lsp/diagnostics.lua index 77b675f..36d502e 100644 --- a/nvim/lua/lsp/diagnostics.lua +++ b/nvim/lua/lsp/diagnostics.lua @@ -1,3 +1,9 @@ +if vim.fn.has("nvim-0.10") == 0 then -- Remove block for v0.10+ release. Covered by vim.diagnostic.config() + vim.fn.sign_define("DiagnosticSignError", { text="", texthl="DiagnosticSignError", linehl="", numhl="" }) + vim.fn.sign_define("DiagnosticSignWarn", { text="", texthl="DiagnosticSignWarn", linehl="", numhl="" }) + vim.fn.sign_define("DiagnosticSignInfo", { text="", texthl="DiagnosticSignInfo", linehl="", numhl="" }) + vim.fn.sign_define("DiagnosticSignHint", { text="", texthl="DiagnosticSignHint", linehl="", numhl="" }) +end vim.diagnostic.config({ signs = { text = { diff --git a/nvim/lua/lsp/init.lua b/nvim/lua/lsp/init.lua index 8720222..30e4d77 100644 --- a/nvim/lua/lsp/init.lua +++ b/nvim/lua/lsp/init.lua @@ -15,4 +15,6 @@ lspconfig.fortls.setup(vim.tbl_deep_extend("error", default_opts, opts.fortls)) require("lsp.keymaps") require("lsp.completion") require("lsp.diagnostics") -require("lsp.inlay") +if vim.lsp.inlay_hint then -- Remove condition for v0.10+ release + require("lsp.inlay") +end From b0cfeb98881bce8f842bd1d7b5b6b8dec55a0d8f Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 10:01:33 -0300 Subject: [PATCH 08/72] feat(LSP): Add some default disables for Pylint Using the FAQ of the project, disabled some checks that are already covered by Flake8. --- pylintrc.toml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pylintrc.toml b/pylintrc.toml index f69e22c..c4f9297 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -3,7 +3,12 @@ [tool.pylint.format] max-line-length = 79 [tool.pylint."messages control"] -#disable = [ +disable = [ + # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters + "bad-indentation", "bare-except", "line-too-long", "missing-final-newline", "multiple-statements", "singleton-comparison", "trailing-whitespace", "unnecessary-semicolon", "unneeded-not", "wrong-import-position", # pycodestyle + "undefined-variable", "unused-import", "unused-variable", # pyflakes + "too-many-branches", # mccabe + + # other stuff # "missing-docstring", "invalid-name", "redefined-outer-name", "logging-format-interpolation", -# "line-too-long", "trailing-whitespace", "trailing-newlines", "wrong-import-position", -#] # Covered in flake8 +] From c774ccf89fded81ee8340e0046d5646a88bcd8d3 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 10:09:10 -0300 Subject: [PATCH 09/72] feat(LSP): Uncomment disable for docstrings in Pylint Disable the check for missing docstrings in Pylint. The check is not covered by other linters, but it will be disabled anyways. --- pylintrc.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylintrc.toml b/pylintrc.toml index c4f9297..024d7c9 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -10,5 +10,6 @@ disable = [ "too-many-branches", # mccabe # other stuff -# "missing-docstring", "invalid-name", "redefined-outer-name", "logging-format-interpolation", + "missing-docstring", + #"invalid-name", "redefined-outer-name", "logging-format-interpolation", ] From 927cfa6a95b18666262a379fb8c8cb72125ec53d Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 10:26:34 -0300 Subject: [PATCH 10/72] feat(LSP): Unfold error message in Pylint disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to message convention, the “missing-docstring” message is unfolded into three separate messages. This change abides to that documentation. --- pylintrc.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylintrc.toml b/pylintrc.toml index 024d7c9..dbbfc77 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -10,6 +10,7 @@ disable = [ "too-many-branches", # mccabe # other stuff - "missing-docstring", + # Unfold "missing-docstring" (https://pylint.rtfd.io/en/latest/user_guide/messages/convention/missing-docstring.html) + "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", #"invalid-name", "redefined-outer-name", "logging-format-interpolation", ] From 03294e28cc7aee47a6fc884e7d042175eb426df6 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 10:33:55 -0300 Subject: [PATCH 11/72] feat(LSP): Break some long lines in pylintrc.toml file --- pylintrc.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylintrc.toml b/pylintrc.toml index dbbfc77..39ae3ff 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -5,7 +5,9 @@ max-line-length = 79 [tool.pylint."messages control"] disable = [ # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters - "bad-indentation", "bare-except", "line-too-long", "missing-final-newline", "multiple-statements", "singleton-comparison", "trailing-whitespace", "unnecessary-semicolon", "unneeded-not", "wrong-import-position", # pycodestyle + "bad-indentation", "bare-except", "line-too-long", "missing-final-newline", # pycodestyle + "multiple-statements", "singleton-comparison", "trailing-whitespace", # pycodestyle + "unnecessary-semicolon", "unneeded-not", "wrong-import-position", # pycodestyle "undefined-variable", "unused-import", "unused-variable", # pyflakes "too-many-branches", # mccabe From 981abbc56ba99398cbda4501e1bbcf5e103090d1 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 11:18:57 -0300 Subject: [PATCH 12/72] feat(LSP): Reorder some Pylint error codes in pylintrc file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reordered in each subset of the “disable” sections, all the error codes according to their numbered error code. Also, renamed an error code documented as such (https://pylint.rtfd.io/en/latest/user_guide/messages/convention/unneeded-not.html) --- pylintrc.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pylintrc.toml b/pylintrc.toml index 39ae3ff..9163359 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -5,9 +5,10 @@ max-line-length = 79 [tool.pylint."messages control"] disable = [ # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters - "bad-indentation", "bare-except", "line-too-long", "missing-final-newline", # pycodestyle - "multiple-statements", "singleton-comparison", "trailing-whitespace", # pycodestyle - "unnecessary-semicolon", "unneeded-not", "wrong-import-position", # pycodestyle + "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle + "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle + "trailing-whitespace", "missing-final-newline", "multiple-statements", # pycodestyle + "wrong-import-position", # pycodestyle "undefined-variable", "unused-import", "unused-variable", # pyflakes "too-many-branches", # mccabe From 7cbc5f95e515b3811994e08e9b83c5fd99c6140e Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 11:26:40 -0300 Subject: [PATCH 13/72] feat(LSP): Add a default clangd configuration In order to achieve the same linting as when compiling a C project, use those default compilation options for linting inside text editors that support clangd LSP. --- clangd/config.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 clangd/config.yaml diff --git a/clangd/config.yaml b/clangd/config.yaml new file mode 100644 index 0000000..78f5476 --- /dev/null +++ b/clangd/config.yaml @@ -0,0 +1,3 @@ +CompileFlags: + Add: [-Wall, -Wextra, -Wpedantic, -std=c2x] + Compiler: gcc # Until clang supports the whole C23 standard From 5e8067677cd52f25bbb0402378645203d5c06fe0 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 11:53:31 -0300 Subject: [PATCH 14/72] feat(templates): Add a clang-format template file As starting with the versioning of templates that can only be used as per-project basis, the clang-format template file and a README are added. --- templates/README.rst | 16 ++++++++++++++++ templates/_clang-format | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 templates/README.rst create mode 100644 templates/_clang-format diff --git a/templates/README.rst b/templates/README.rst new file mode 100644 index 0000000..04f01d0 --- /dev/null +++ b/templates/README.rst @@ -0,0 +1,16 @@ +Templates +========= + +This directory bundles templates of config files for different kind of +projects. + +The purpose of files here, is that for these tools there is no global/user +configuration that can be used as a common base, but instead, these tools can +only be configured per-project adding config files to the base dir of the +corresponding project. + +Therefore, here are a bunch of files that with minimum or non changes can be +copied into project's base directories for configuring them. + +There are templates for tools for different technologies. Depending on +technologies used in each project is which files should be copied. diff --git a/templates/_clang-format b/templates/_clang-format new file mode 100644 index 0000000..6a20952 --- /dev/null +++ b/templates/_clang-format @@ -0,0 +1,8 @@ +BasedOnStyle: llvm +IndentWidth: 4 +TabWidth: 4 +UseTab: ForIndentation +BreakBeforeBinaryOperators: NonAssignment +SpaceAfterCStyleCast: true +AlignTrailingComments: false +SpacesBeforeTrailingComments: 2 From 8550e82f06c00b1847709c878985e957ef44b59a Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 12:54:24 -0300 Subject: [PATCH 15/72] feat(templates): Add some templates for Makefiles The purpose of this Makefile and base.mk files are to emulate the behavior of command `make` when only given a build target (inferring the source file to use); but using instead a custom set of building flags. base.mk holds those custom set of building flags, Makefile is just the wrapper to add get the target name and source file. --- templates/Makefile | 4 ++++ templates/base.mk | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 templates/Makefile create mode 100644 templates/base.mk diff --git a/templates/Makefile b/templates/Makefile new file mode 100644 index 0000000..9d4d982 --- /dev/null +++ b/templates/Makefile @@ -0,0 +1,4 @@ +-include base.mk + +TARGET = appname +all: $(TARGET) diff --git a/templates/base.mk b/templates/base.mk new file mode 100644 index 0000000..0769d3c --- /dev/null +++ b/templates/base.mk @@ -0,0 +1,6 @@ +BUILD ?= debug + +CFLAGS ?= -Wall -Wextra -std=c2x -Wpedantic +cflags.debug = -g -DDEBUG +cflags.release = -O2 -Werror +CFLAGS += ${cflags.${BUILD}} From eb2204a5676e284e65bc01e00970669e29912ec2 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:23:05 -0300 Subject: [PATCH 16/72] feat(LSP): Minor whitespace fix --- pylintrc.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylintrc.toml b/pylintrc.toml index 9163359..56288bd 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -6,7 +6,7 @@ max-line-length = 79 disable = [ # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle - "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle + "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle "trailing-whitespace", "missing-final-newline", "multiple-statements", # pycodestyle "wrong-import-position", # pycodestyle "undefined-variable", "unused-import", "unused-variable", # pyflakes From 83c1c4f10d542204a579fafe6507d761717e4a02 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:24:07 -0300 Subject: [PATCH 17/72] feat(LSP): Add missing duplicate Pylint message Added a newly found Pylint message that's duplicated by pycodestyle (via Flake8). This message wasn't on the documentation but has a PR and is awaiting approval. --- pylintrc.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylintrc.toml b/pylintrc.toml index 56288bd..a542805 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -7,8 +7,8 @@ disable = [ # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle - "trailing-whitespace", "missing-final-newline", "multiple-statements", # pycodestyle - "wrong-import-position", # pycodestyle + "trailing-whitespace", "missing-final-newline", "trailing-newlines", # pycodestyle + "multiple-statements", "wrong-import-position", # pycodestyle "undefined-variable", "unused-import", "unused-variable", # pyflakes "too-many-branches", # mccabe From ede333abc5932d596bd45e069fa7a490028a31ca Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:29:06 -0300 Subject: [PATCH 18/72] feat(templates): Add first attempt at a pyproject.toml template Added ruff rules copied from ruff.toml but changing the max-line-length argument. --- templates/pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 templates/pyproject.toml diff --git a/templates/pyproject.toml b/templates/pyproject.toml new file mode 100644 index 0000000..93dbc2d --- /dev/null +++ b/templates/pyproject.toml @@ -0,0 +1,6 @@ +[tool.ruff] +line-length = 120 +extend-select = [ + "E", "W", "F", "C90", # Pycodestyle + Pyflakes + McCabe = Flake8 + "PL", # Pylint +] From 43bf852b711ef8a8d9c0fdd92d3985f6da1da227 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:43:44 -0300 Subject: [PATCH 19/72] feat(templates): Add default exclusion for Ruff --- templates/pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 93dbc2d..960ae16 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -4,3 +4,5 @@ extend-select = [ "E", "W", "F", "C90", # Pycodestyle + Pyflakes + McCabe = Flake8 "PL", # Pylint ] +[tool.ruff.per-file-ignores] +"__init__.py" = ["F401"] From 4025066a193707d578266e916c7344f76d82155c Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:45:25 -0300 Subject: [PATCH 20/72] feat(templates): Add Flake8 defaults in pyproject.toml --- templates/pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 960ae16..8ce7050 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -6,3 +6,9 @@ extend-select = [ ] [tool.ruff.per-file-ignores] "__init__.py" = ["F401"] + +[tool.flake8] +max-line-length = 120 +per-file-ignores = [ + "__init__.py:F401", +] From 2f9692c1e390ea591af2d9028aeff1b73832e1e7 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 16:47:05 -0300 Subject: [PATCH 21/72] feat(templates): Add defaults for Pylint in pyproject.toml Also included some duplicated messages that can be excluded because they are already covered by other linters. --- templates/pyproject.toml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 8ce7050..fc3af15 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -12,3 +12,19 @@ max-line-length = 120 per-file-ignores = [ "__init__.py:F401", ] + +[tool.pylint.format] +max-line-length = 120 +[tool.pylint."messages control"] +disable = [ + # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters + "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle + "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle + "trailing-whitespace", "missing-final-newline", "trailing-newlines", # pycodestyle + "multiple-statements", "wrong-import-position", # pycodestyle + "undefined-variable", "unused-import", "unused-variable", # pyflakes + "too-many-branches", # mccabe + + # other stuff + "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", +] From 4e30f2806f68616fe712259550eb6f15b80e9917 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 18:59:42 -0300 Subject: [PATCH 22/72] feat(templates): Add mypy base settings to pyproject.toml --- templates/pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index fc3af15..51bbe66 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -28,3 +28,9 @@ disable = [ # other stuff "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", ] + +[tool.mypy] +ignore_missing_imports = true +follow_imports = "silent" +show_column_numbers = true +show_error_codes = true From 741ad520529736db3c0ae422e582b85f550a27ec Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 19:25:52 -0300 Subject: [PATCH 23/72] feat(templates): Add some comments explaining --- templates/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 51bbe66..0e1bf7f 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -8,6 +8,7 @@ extend-select = [ "__init__.py" = ["F401"] [tool.flake8] +# This category requires “Flake8-pyproject” plugin to take effect max-line-length = 120 per-file-ignores = [ "__init__.py:F401", From 0d08a423d30bf52bd4546714b1278cf39e021f6a Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 19:29:10 -0300 Subject: [PATCH 24/72] feat(LSP): Add minimum configuration to Fourmolu. --- fourmolu.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 fourmolu.yaml diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000..323d104 --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1 @@ +column-limit: 80 From 56ca26d49300d29cfff586696360c5ea13ea01d8 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 19:31:08 -0300 Subject: [PATCH 25/72] feat(Pylint): Add nice configurations to pytest This configurations are intended to be used as either, user configuration, or in a project. --- pytest.ini | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..017eb03 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +addopts = --pdbcls=IPython.terminal.debugger:TerminalPdb --tb=short --quiet + --disable-pytest-warnings --no-cov From 7ac935e2ca37eee1e7ab3409027c151a8dfb6582 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 23 Jan 2024 19:43:13 -0300 Subject: [PATCH 26/72] feat(templates): Add some nice defaults for Pylint --- templates/pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 0e1bf7f..ff746ae 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -35,3 +35,11 @@ ignore_missing_imports = true follow_imports = "silent" show_column_numbers = true show_error_codes = true + +[tool.pytest.ini_options] +addopts = """ +--pdbcls=IPython.terminal.debugger:TerminalPdb --tb=short --quiet +--disable-pytest-warnings --no-cov +""" +log_level = "INFO" +python_files = ["*_tests.py", "tests.py"] From b20481142655829e51e69ed8c53aecd0e156ede7 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 24 Jan 2024 17:16:19 -0300 Subject: [PATCH 27/72] feat(Git): Add nice default date format for blame --- git/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git/config b/git/config index a5bd192..29cc745 100644 --- a/git/config +++ b/git/config @@ -10,3 +10,5 @@ lg = less -S [tar "tar.xz"] command = xz -c +[blame] + date = relative From 1880c45bc8068343765702cca4172f1cd39e0cde Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 24 Jan 2024 17:25:27 -0300 Subject: [PATCH 28/72] feat(templates): Update default C standard in Makefile --- templates/base.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.mk b/templates/base.mk index 0769d3c..b1f84c1 100644 --- a/templates/base.mk +++ b/templates/base.mk @@ -1,6 +1,6 @@ BUILD ?= debug -CFLAGS ?= -Wall -Wextra -std=c2x -Wpedantic +CFLAGS ?= -Wall -Wextra -std=c23 -Wpedantic cflags.debug = -g -DDEBUG cflags.release = -O2 -Werror CFLAGS += ${cflags.${BUILD}} From fa9077a603dbf31f0aede1e939048db3e0b789d1 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 24 Jan 2024 17:49:48 -0300 Subject: [PATCH 29/72] feat(LSP): Change functionality in diagnostics pop-up Now, the automatic pop-up that appears when the cursor is idle, appears en both, Normal and Insert modes; and only displays messages under the cursor, not the entire line. For the other behavior, there is still the keybinding ``+`e`. --- nvim/lua/lsp/diagnostics.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nvim/lua/lsp/diagnostics.lua b/nvim/lua/lsp/diagnostics.lua index 77b675f..e95a224 100644 --- a/nvim/lua/lsp/diagnostics.lua +++ b/nvim/lua/lsp/diagnostics.lua @@ -18,12 +18,16 @@ vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id) - vim.api.nvim_create_autocmd("CursorHoldI", { + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { group = vim.api.nvim_create_augroup("Diagnostics", { clear = true }), buffer = bufnr, callback = function() - vim.diagnostic.open_float({ focusable = false, header = "" }) - end + vim.diagnostic.open_float({ + focusable = false, + header = "", + scope = "cursor", + }) + end, }) end, }) From 8c40b02eda9b2d14542b076903aa92c5ecf8c0ba Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 24 Jan 2024 22:23:04 -0300 Subject: [PATCH 30/72] feat(templates): Add a pre-commit template for Python project hooks --- templates/_pre-commit-config.yaml | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 templates/_pre-commit-config.yaml diff --git a/templates/_pre-commit-config.yaml b/templates/_pre-commit-config.yaml new file mode 100644 index 0000000..ba6fc09 --- /dev/null +++ b/templates/_pre-commit-config.yaml @@ -0,0 +1,77 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + exclude: .chart/ + - id: check-added-large-files + +- repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + args: [--max-line-length=120] + language: system # don't commit!! + +- repo: https://github.com/PyCQA/pylint + rev: v2.15.5 + hooks: + - id: pylint + args: [ + --max-line-length=120, + "--disable=missing-docstring,invalid-name,redefined-outer-name,logging-format-interpolation,too-many-ancestors,too-few-public-methods", + --disable=import-error, + --max-args=7, + ] + # disabled plugins: pylint.extensions.mccabe + exclude: tests|tests/input|tests/extensions/data|tests/regrtest_data|tests/data|doc + language: system # don't commit!! + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.982 + hooks: + - id: mypy + args: [ + --ignore-missing-imports, + --follow-imports=silent, + --show-column-numbers, + ] + additional_dependencies: [types-all] + #exclude: migrations/ + language: system # don't commit!! + +- repo: https://github.com/asottile/pyupgrade + rev: v3.2.0 + hooks: + - id: pyupgrade + args: [--py311-plus] + args: [--py36-plus] + +- repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + name: isort (python) + args: [--check-only, --line-length=120, --diff] + args: [--check-only, --profile=django, --line-length=120, --diff, --py=36, --src=ceg/] + +- repo: https://github.com/jazzband/pip-tools + rev: 5.3.1 + hooks: + - id: pip-compile + name: pip-compile setup.py + files: ^(setup\.py|requirements\.txt)$ + - id: pip-compile + name: pip-compile requirements-dev.in + args: [requirements-dev.in] + files: ^requirements-dev\.(in|txt)$ + - id: pip-compile + name: pip-compile requirements-lint.in + args: [requirements-lint.in] + files: ^requirements-lint\.(in|txt)$ + - id: pip-compile + name: pip-compile requirements.txt + args: [requirements.txt] + files: ^requirements\.(in|txt)$ From 9b659ae6dd796a6ecebb2ba540548f6ea14395d3 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 24 Jan 2024 22:28:18 -0300 Subject: [PATCH 31/72] feat(templates): Bump some hook's versions --- templates/_pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/_pre-commit-config.yaml b/templates/_pre-commit-config.yaml index ba6fc09..d2bffc6 100644 --- a/templates/_pre-commit-config.yaml +++ b/templates/_pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -9,14 +9,14 @@ repos: - id: check-added-large-files - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 args: [--max-line-length=120] language: system # don't commit!! - repo: https://github.com/PyCQA/pylint - rev: v2.15.5 + rev: v3.0.3 hooks: - id: pylint args: [ @@ -30,7 +30,7 @@ repos: language: system # don't commit!! - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v1.8.0 hooks: - id: mypy args: [ @@ -43,14 +43,14 @@ repos: language: system # don't commit!! - repo: https://github.com/asottile/pyupgrade - rev: v3.2.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py311-plus] args: [--py36-plus] - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort name: isort (python) @@ -58,7 +58,7 @@ repos: args: [--check-only, --profile=django, --line-length=120, --diff, --py=36, --src=ceg/] - repo: https://github.com/jazzband/pip-tools - rev: 5.3.1 + rev: 7.3.0 hooks: - id: pip-compile name: pip-compile setup.py From 82d55e62316a0bdec8bf41ddc6218ed9e32b1b5d Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Thu, 25 Jan 2024 13:11:17 -0300 Subject: [PATCH 32/72] feat(Neovim/Vim): Add some basic folding functionality --- nvim/init.vim | 6 ++++++ vim/vimrc | 3 +++ 2 files changed, 9 insertions(+) diff --git a/nvim/init.vim b/nvim/init.vim index f3a2220..a13fea9 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -52,6 +52,12 @@ command -nargs=? Terminal rightbelow 16split +terminal\ nnoremap tt :rightbelow 16split +terminal tnoremap p +set foldcolumn=auto:4 +set foldlevelstart=99 +set foldmethod=expr +set foldexpr=v:lua.vim.treesitter.foldexpr() +set foldtext=v:lua.vim.treesitter.foldtext() + " Theming let g:aldmeris_transparent = v:true let g:aldmeris_termcolors = 'tango' diff --git a/vim/vimrc b/vim/vimrc index 875f870..5839aaa 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -45,6 +45,9 @@ command -nargs=? Terminal rightbelow terminal ++rows=16 nnoremap tt :rightbelow terminal ++rows=16 tnoremap p +set foldcolumn=4 +set foldlevelstart=99 + " Theming let g:aldmeris_transparent = v:true let g:aldmeris_termcolors = 'tango' From 72fc1f42444a3f8352496e041087c6c7ac435492 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Thu, 25 Jan 2024 20:44:23 -0300 Subject: [PATCH 33/72] feat(Vim): Add some extra folding functionality Not quite working yet, but is the first attempt to mimic Treesitter's functionality in Neovim. --- vim/vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index 5839aaa..65461e0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -47,6 +47,9 @@ tnoremap p set foldcolumn=4 set foldlevelstart=99 +set foldmethod=expr +set foldexpr=coc#util#refactor_foldlevel(v:lnum) +set foldtext=coc#util#refactor_fold_text(v:foldstart) " Theming let g:aldmeris_transparent = v:true From ae1d9a6043e94e920f2dfdc37ae2815ac7fc1ec5 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 26 Jan 2024 10:04:08 -0300 Subject: [PATCH 34/72] feat(Fish): Set default editor to Neovim Using the recommendation in the FAQ (https://fishshell.com/docs/current/faq.html#why-doesn-t-set-ux-exported-universal-variables-seem-to-work), set the `EDITOR` environment variable to `nvim`. --- fish/config.fish | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fish/config.fish b/fish/config.fish index 0a06a0f..1adfb95 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -2,3 +2,5 @@ if status is-interactive # Commands to run in interactive sessions can go here [ -r $HOME/.sh.d/aliases ] && . $HOME/.sh.d/aliases end + +set -gx EDITOR nvim From 5971e6e019d91a59459b8f75dd0c152b9827c2d3 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 26 Jan 2024 12:30:44 -0300 Subject: [PATCH 35/72] feat(shells): Add an alias for vi to run nvim This fallback is in case an app ignores the `EDITOR` env variable, and directly runs the command `vi` as a default for tui text editor. --- shells/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/shells/aliases b/shells/aliases index 5143376..ce96a59 100644 --- a/shells/aliases +++ b/shells/aliases @@ -2,5 +2,6 @@ alias ls="ls --color=auto" alias rm="rm -i" alias cp="cp -i" alias mv="mv -i" +alias vi=nvim alias grep="grep --color=auto" alias less="less --LONG-PROMPT --LINE-NUMBERS" From 97e405293434f9d10803830ccbfefa541fd721b2 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 26 Jan 2024 13:48:02 -0300 Subject: [PATCH 36/72] feat(LSP): Delete erroneous argument `buffer` The argument `buffer` us used for another type of autocmd's, those with whole buffer scope. --- nvim/lua/lsp/diagnostics.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/nvim/lua/lsp/diagnostics.lua b/nvim/lua/lsp/diagnostics.lua index 0a216e7..2df1ef9 100644 --- a/nvim/lua/lsp/diagnostics.lua +++ b/nvim/lua/lsp/diagnostics.lua @@ -26,7 +26,6 @@ vim.api.nvim_create_autocmd("LspAttach", { local client = vim.lsp.get_client_by_id(args.data.client_id) vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { group = vim.api.nvim_create_augroup("Diagnostics", { clear = true }), - buffer = bufnr, callback = function() vim.diagnostic.open_float({ focusable = false, From bd061bf7b30e5c285b7030da6c5262afdf0fe107 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 26 Jan 2024 13:50:01 -0300 Subject: [PATCH 37/72] feat(LSP): Delete unused variables There is no need for these variables under this auto-command. --- nvim/lua/lsp/diagnostics.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nvim/lua/lsp/diagnostics.lua b/nvim/lua/lsp/diagnostics.lua index 2df1ef9..ece4da4 100644 --- a/nvim/lua/lsp/diagnostics.lua +++ b/nvim/lua/lsp/diagnostics.lua @@ -21,9 +21,7 @@ vim.diagnostic.config({ vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", { clear = false }), - callback = function(args) - local bufnr = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) + callback = function() vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { group = vim.api.nvim_create_augroup("Diagnostics", { clear = true }), callback = function() From ea03e3300a561b93223a601b79f57f6e0632c019 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 29 Jan 2024 05:43:31 -0300 Subject: [PATCH 38/72] feat(Neovim): Correct folding options The function that added nice text for folded blocks was reverted in https://github.com/neovim/neovim/pull/27217 in favor of the default text generated by setting the folding-text option to `""`. --- nvim/init.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index a13fea9..7037086 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -55,8 +55,9 @@ tnoremap p set foldcolumn=auto:4 set foldlevelstart=99 set foldmethod=expr -set foldexpr=v:lua.vim.treesitter.foldexpr() -set foldtext=v:lua.vim.treesitter.foldtext() +set foldexpr=nvim_treesitter#foldexpr() +set foldtext="" +set nofoldenable " Theming let g:aldmeris_transparent = v:true From 9a003190ed84a3c7ebe0462cdbd07c75df84a3ff Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 29 Jan 2024 05:47:24 -0300 Subject: [PATCH 39/72] feat(Vim): Turn off folding display by default --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index 65461e0..7bb4ae0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -50,6 +50,7 @@ set foldlevelstart=99 set foldmethod=expr set foldexpr=coc#util#refactor_foldlevel(v:lnum) set foldtext=coc#util#refactor_fold_text(v:foldstart) +set nofoldenable " Theming let g:aldmeris_transparent = v:true From 1ca997c674a82e91f8a673934b4775a5a44252f0 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 31 Jan 2024 00:12:00 -0300 Subject: [PATCH 40/72] feat(mypy): Reorder some options in preference order --- mypy/config | 2 +- templates/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/config b/mypy/config index edc93f3..a7133c6 100644 --- a/mypy/config +++ b/mypy/config @@ -1,7 +1,7 @@ [mypy] +show_column_numbers = True ignore_missing_imports = True follow_imports = silent -show_column_numbers = True show_error_codes = True warn_unused_configs = True diff --git a/templates/pyproject.toml b/templates/pyproject.toml index ff746ae..25a38ae 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -31,9 +31,9 @@ disable = [ ] [tool.mypy] +show_column_numbers = true ignore_missing_imports = true follow_imports = "silent" -show_column_numbers = true show_error_codes = true [tool.pytest.ini_options] From 848d6377f1e5b7482dfdc41258aa1cf5c133797b Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 31 Jan 2024 00:15:30 -0300 Subject: [PATCH 41/72] feat(mypy): Change configuration format Changed mypy configuration file format from INI to TOML. It works all the same and in this way there are more similarities with the format inside pyproject.toml file. --- mypy/config | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mypy/config b/mypy/config index a7133c6..fa64f32 100644 --- a/mypy/config +++ b/mypy/config @@ -1,19 +1,19 @@ [mypy] -show_column_numbers = True -ignore_missing_imports = True -follow_imports = silent -show_error_codes = True +show_column_numbers = true +ignore_missing_imports = true +follow_imports = "silent" +show_error_codes = true -warn_unused_configs = True -allow_any_generics = False -allow_subclassing_any = False -allow_untyped_calls = False -allow_untyped_defs = False -allow_incomplete_defs = False -check_untyped_defs = True -allow_untyped_decorators = False -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -implicit_reexport = False +warn_unused_configs = true +allow_any_generics = false +allow_subclassing_any = false +allow_untyped_calls = false +allow_untyped_defs = false +allow_incomplete_defs = false +check_untyped_defs = true +allow_untyped_decorators = false +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +implicit_reexport = false From 7a260bf0da957bc3359dafa94a98c253c98aee09 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 12:00:45 -0300 Subject: [PATCH 42/72] feat(emacs): Move settings outside customize Emacs customization interface has it's own way to sort settings out. With this change, the same settings' effects are achieved manually without having to rely on the internal sorting the customize interface intends. --- emacs/init.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index b06a87b..37c31e6 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -1,9 +1,9 @@ -(custom-set-variables - '(custom-enabled-themes '(tango-dark)) - '(display-line-numbers-type 'relative) - '(column-number-mode t) - '(truncate-lines t) - '(tool-bar-mode nil)) +(load-theme 'tango-dark t) +(setq display-line-numbers-type 'relative) +(setq column-number-mode t) +(setq-default truncate-lines t) +(tool-bar-mode -1) + (custom-set-faces '(default ((t (:family "Iosevka Curly Slab" :foundry "UKWN" :slant normal :weight regular :height 113 :width normal))))) (add-hook 'prog-mode-hook #'display-line-numbers-mode) From 881a3b70ce1676a2ab17d1e734b90053398bf687 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 12:38:52 -0300 Subject: [PATCH 43/72] feat(emacs): Move font attributes outside custom-set-font As with previous change, the custom-set-font interface reorders stuff it's own way. Moving this settings outside that scope makes the settings stay put. --- emacs/init.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 37c31e6..9d1c53e 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -4,7 +4,8 @@ (setq-default truncate-lines t) (tool-bar-mode -1) -(custom-set-faces - '(default ((t (:family "Iosevka Curly Slab" :foundry "UKWN" :slant normal :weight regular :height 113 :width normal))))) +(set-face-attribute + 'default nil :family "Iosevka Curly Slab" :foundry "UKWN" :slant 'normal :weight 'regular :height 113 :width 'normal) + (add-hook 'prog-mode-hook #'display-line-numbers-mode) (when window-system (set-frame-size (selected-frame) 85 60)) From a272a609a39c07eb94c2caf5663d846eca18879f Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 12:53:02 -0300 Subject: [PATCH 44/72] feat(emacs): Split lines in setting for readability --- emacs/init.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 9d1c53e..7717848 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -4,8 +4,13 @@ (setq-default truncate-lines t) (tool-bar-mode -1) -(set-face-attribute - 'default nil :family "Iosevka Curly Slab" :foundry "UKWN" :slant 'normal :weight 'regular :height 113 :width 'normal) +(set-face-attribute 'default nil + :family "Iosevka Curly Slab" + :foundry "UKWN" + :slant 'normal + :weight 'regular + :height 113 + :width 'normal) (add-hook 'prog-mode-hook #'display-line-numbers-mode) (when window-system (set-frame-size (selected-frame) 85 60)) From 584deb9575085e48da0109936c093df0cffd3993 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 15:11:14 -0300 Subject: [PATCH 45/72] feat(emacs): Remember last cursor position per file --- emacs/init.el | 1 + 1 file changed, 1 insertion(+) diff --git a/emacs/init.el b/emacs/init.el index 7717848..83d1bac 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -1,5 +1,6 @@ (load-theme 'tango-dark t) (setq display-line-numbers-type 'relative) +(save-place-mode 1) (setq column-number-mode t) (setq-default truncate-lines t) (tool-bar-mode -1) From 4ef1f32186e99f1f0e6715b06de7d1d7fccd34e5 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 20:17:30 -0300 Subject: [PATCH 46/72] feat(emacs): Setup some packages for emacs Similar to a plugin manager, Emacs has Elpa and Melpa repos. Here, Melpa repository is being added and then some packages (themes and languages' modes) provided by that repo. --- emacs/init.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/emacs/init.el b/emacs/init.el index 83d1bac..b4bdba1 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -15,3 +15,16 @@ (add-hook 'prog-mode-hook #'display-line-numbers-mode) (when window-system (set-frame-size (selected-frame) 85 60)) + +; After dealing with some nice defaults setup packages +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(package-initialize) + +(use-package vscode-dark-plus-theme + :ensure t + :config + (load-theme 'vscode-dark-plus t)) + +(use-package rust-mode :ensure t) +(use-package haskell-mode :ensure t) From 13920d3841a894c8a29ad3cec35f5fdebf63aa96 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 20:20:43 -0300 Subject: [PATCH 47/72] feat(emacs): Delete unused option for typeface --- emacs/init.el | 1 - 1 file changed, 1 deletion(-) diff --git a/emacs/init.el b/emacs/init.el index b4bdba1..0993b0f 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -7,7 +7,6 @@ (set-face-attribute 'default nil :family "Iosevka Curly Slab" - :foundry "UKWN" :slant 'normal :weight 'regular :height 113 From e5a65b3ea9a5fc966c62e4cc7be76273a6e46ba2 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 20:30:16 -0300 Subject: [PATCH 48/72] feat(emacs): Add some LSP functionality to Emacs This feature requires for LSP servers to be already installed, and the PATH variable to point to where the executables reside. --- emacs/init.el | 1 + 1 file changed, 1 insertion(+) diff --git a/emacs/init.el b/emacs/init.el index 0993b0f..1e8b977 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -13,6 +13,7 @@ :width 'normal) (add-hook 'prog-mode-hook #'display-line-numbers-mode) +(add-hook 'prog-mode-hook 'eglot-ensure) ; Requires LSP servers in PATH (when window-system (set-frame-size (selected-frame) 85 60)) ; After dealing with some nice defaults setup packages From 00a57f889c7b82f93c9ab8daa08b9223a5d3dc40 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 31 Jan 2024 00:15:30 -0300 Subject: [PATCH 49/72] feat(mypy): Change configuration format Changed mypy configuration INI format. Python's configparser checks boolean values in a case-insensitive manner, so it doesn't matter if values start in Title-case or lower-case. This way, the configuration is easily translated to TOML format for writing a pyproject.toml file; with the exception of string values which will have to be enclosed in quotes anyways. --- mypy/config | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mypy/config b/mypy/config index a7133c6..da83f18 100644 --- a/mypy/config +++ b/mypy/config @@ -1,19 +1,19 @@ [mypy] -show_column_numbers = True -ignore_missing_imports = True +show_column_numbers = true +ignore_missing_imports = true follow_imports = silent -show_error_codes = True +show_error_codes = true -warn_unused_configs = True -allow_any_generics = False -allow_subclassing_any = False -allow_untyped_calls = False -allow_untyped_defs = False -allow_incomplete_defs = False -check_untyped_defs = True -allow_untyped_decorators = False -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -implicit_reexport = False +warn_unused_configs = true +allow_any_generics = false +allow_subclassing_any = false +allow_untyped_calls = false +allow_untyped_defs = false +allow_incomplete_defs = false +check_untyped_defs = true +allow_untyped_decorators = false +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +implicit_reexport = false From 6d2951b2b18110a3deb718d34a1d7432611e6484 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 3 Feb 2024 23:31:59 -0300 Subject: [PATCH 50/72] feat(LSP): Amend documentation This is a minimal correction on the comments documenting the use of the file. --- flake8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake8 b/flake8 index de9c84f..24bd7e8 100644 --- a/flake8 +++ b/flake8 @@ -1,4 +1,6 @@ -# Not in official documentation, but it can be placed in $XDG_CONFIG_HOME +# This does not work from $XDG_CONFIG_HOME, but python-lsp-server looks for it +# in that location anyways. This is explicitly achieved here: +# https://github.com/python-lsp/python-lsp-server/blob/fc2851a/pylsp/config/flake8_conf.py#L52 [flake8] max-line-length = 79 #extend-ignore = E501, W293, W391, E402, W503 # Those are also checked by pylint From 54938dd02ca3ac6db334bd1b532293851cda9d20 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sun, 4 Feb 2024 18:33:28 -0300 Subject: [PATCH 51/72] feat(LSP): Add PyLSP configurations for eglot Replicate the same base configuration used for python-lsp-server in Neovim but for Emacs's Eglot LSP client. --- emacs/init.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emacs/init.el b/emacs/init.el index 1e8b977..e21eb14 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -14,6 +14,14 @@ (add-hook 'prog-mode-hook #'display-line-numbers-mode) (add-hook 'prog-mode-hook 'eglot-ensure) ; Requires LSP servers in PATH +(setq-default eglot-workspace-configuration + '(:pylsp (:configurationSources ["flake8"] + :plugins (:ruff (:enabled t) + :flake8 (:enabled t) + :pylint (:enabled t) + :pylsp_mypy (:enabled t) + :pycodestyle (:enabled nil) + :pyflakes (:enabled nil))))) (when window-system (set-frame-size (selected-frame) 85 60)) ; After dealing with some nice defaults setup packages From 6b5452f9d17b24f143b77689cd9d7bfaa60131bd Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 6 Feb 2024 08:06:18 -0300 Subject: [PATCH 52/72] feat(LSP): Add pylint executable explicitly Without telling python-lsp-server which the pylint executable is, explicitly, the plugin never runs. This modification ensures the plugin is running. --- emacs/init.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emacs/init.el b/emacs/init.el index e21eb14..466894f 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -18,7 +18,8 @@ '(:pylsp (:configurationSources ["flake8"] :plugins (:ruff (:enabled t) :flake8 (:enabled t) - :pylint (:enabled t) + :pylint (:enabled t + :executable "pylint") :pylsp_mypy (:enabled t) :pycodestyle (:enabled nil) :pyflakes (:enabled nil))))) From f248c257bd2028bb493473544c6c3807ede768c6 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 6 Feb 2024 08:08:24 -0300 Subject: [PATCH 53/72] fix(LSP): Correct pylsp configuration syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eglot's configuration for LSP servers does not have a “false” literal in Lisp. Furthermore, the previously used `nil` value was being mapped to JSON's `null` value instead of `false`; making the LSP server to load defaults for those settings instead of setting those settings to false. --- emacs/init.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 466894f..555cfc4 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -21,8 +21,8 @@ :pylint (:enabled t :executable "pylint") :pylsp_mypy (:enabled t) - :pycodestyle (:enabled nil) - :pyflakes (:enabled nil))))) + :pycodestyle (:enabled :json-false) + :pyflakes (:enabled :json-false))))) (when window-system (set-frame-size (selected-frame) 85 60)) ; After dealing with some nice defaults setup packages From 52cd15c96df42adc9bbd1d70c20fdb4697d3a29a Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 6 Feb 2024 08:12:08 -0300 Subject: [PATCH 54/72] feat(emacs): Upgrade package initialization syntax Previously used syntax for adding Melpa's repository to Emacs was taken from Melpa's site itself. But some of those commands have become standard Emacs that load on Emacs startup. This changes are to make use of newer techniques for incorporating 3rd party repos into Emacs. --- emacs/init.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index e21eb14..991eab9 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -25,9 +25,8 @@ (when window-system (set-frame-size (selected-frame) 85 60)) ; After dealing with some nice defaults setup packages -(require 'package) -(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) -(package-initialize) +(with-eval-after-load 'package + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)) (use-package vscode-dark-plus-theme :ensure t From 7dfa03eb73ec82474eb808b8145ed707b6825ad1 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 6 Feb 2024 08:59:57 -0300 Subject: [PATCH 55/72] feat(LSP): Delete default flag from config The flag being deleted already has its default value set to what was on the configuration file. Having the configuration was redundant. --- mypy/config | 1 - 1 file changed, 1 deletion(-) diff --git a/mypy/config b/mypy/config index da83f18..b34b27e 100644 --- a/mypy/config +++ b/mypy/config @@ -2,7 +2,6 @@ show_column_numbers = true ignore_missing_imports = true follow_imports = silent -show_error_codes = true warn_unused_configs = true allow_any_generics = false From b887f0b9ae5c63d069d5af289d396c812c6a088d Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Tue, 6 Feb 2024 09:02:19 -0300 Subject: [PATCH 56/72] feat(LSP): Add nice pretty output for Mypy --- mypy/config | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/config b/mypy/config index b34b27e..24b4750 100644 --- a/mypy/config +++ b/mypy/config @@ -1,5 +1,6 @@ [mypy] show_column_numbers = true +pretty = true ignore_missing_imports = true follow_imports = silent From a1dbef0b648d3712af713e7e28ff33f671a0f5e1 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 23 Feb 2024 17:39:06 -0300 Subject: [PATCH 57/72] feat(LSP): Copy behavior for Mypy on pyproject The results achieved in the Mypy config files, translate them to the pyproject.toml in order to have the very same behavior. --- templates/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 25a38ae..1951c2e 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -32,9 +32,9 @@ disable = [ [tool.mypy] show_column_numbers = true +pretty = true ignore_missing_imports = true follow_imports = "silent" -show_error_codes = true [tool.pytest.ini_options] addopts = """ From 4dfdba8ac71d72b2521572c32aec128a831c021c Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 23 Feb 2024 17:42:29 -0300 Subject: [PATCH 58/72] feat(LSP): Bump configuration for Ruff With latest Ruff version, some of the settings in the configuration files were relocated. This patch corrects those category names. --- ruff/ruff.toml | 1 + templates/pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ruff/ruff.toml b/ruff/ruff.toml index be08ba5..dc63745 100644 --- a/ruff/ruff.toml +++ b/ruff/ruff.toml @@ -1,4 +1,5 @@ line-length = 79 +[lint] extend-select = [ "E", "W", "F", "C90", # Pycodestyle + Pyflakes + McCabe = Flake8 "PL", # Pylint diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 1951c2e..bcc35d3 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -1,10 +1,11 @@ [tool.ruff] line-length = 120 +[tool.ruff.lint] extend-select = [ "E", "W", "F", "C90", # Pycodestyle + Pyflakes + McCabe = Flake8 "PL", # Pylint ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] [tool.flake8] From 11a1962f095a4be64714ea3cd28e253a2fd5ffe9 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 23 Feb 2024 17:51:36 -0300 Subject: [PATCH 59/72] feat(LSP): Correct Pylint's configuration indentation Unify Pylint's config indentation like any other TOML file in this repo. --- pylintrc.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pylintrc.toml b/pylintrc.toml index a542805..c862ef9 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -4,16 +4,16 @@ max-line-length = 79 [tool.pylint."messages control"] disable = [ - # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters - "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle - "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle - "trailing-whitespace", "missing-final-newline", "trailing-newlines", # pycodestyle - "multiple-statements", "wrong-import-position", # pycodestyle - "undefined-variable", "unused-import", "unused-variable", # pyflakes - "too-many-branches", # mccabe + # Covered in flake8 according to https://pylint.rtfd.io/en/latest/faq.html#which-messages-should-i-disable-to-avoid-duplicates-if-i-use-other-popular-linters + "unnecessary-semicolon", "bad-indentation", "bare-except", # pycodestyle + "unnecessary-negation", "singleton-comparison", "line-too-long", # pycodestyle + "trailing-whitespace", "missing-final-newline", "trailing-newlines", # pycodestyle + "multiple-statements", "wrong-import-position", # pycodestyle + "undefined-variable", "unused-import", "unused-variable", # pyflakes + "too-many-branches", # mccabe - # other stuff - # Unfold "missing-docstring" (https://pylint.rtfd.io/en/latest/user_guide/messages/convention/missing-docstring.html) - "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", - #"invalid-name", "redefined-outer-name", "logging-format-interpolation", + # other stuff + # Unfold "missing-docstring" (https://pylint.rtfd.io/en/latest/user_guide/messages/convention/missing-docstring.html) + "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", + #"invalid-name", "redefined-outer-name", "logging-format-interpolation", ] From 773acf8ec4bf3a2c039bf549e0d5d4f194eb3a29 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Fri, 23 Feb 2024 17:59:03 -0300 Subject: [PATCH 60/72] feat(LSP): Correct Ruff config section to mimic covered linters In order to make Ruff report, the best way possible, mimicking the reports provided by both Flake8 and Pylint, disable some of the checks that the latter linters don't have turned on by default. --- templates/pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index bcc35d3..254a5b7 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -2,9 +2,13 @@ line-length = 120 [tool.ruff.lint] extend-select = [ - "E", "W", "F", "C90", # Pycodestyle + Pyflakes + McCabe = Flake8 + "E", "W", "F", # Pycodestyle + Pyflakes - McCabe (C90) = Flake8 "PL", # Pylint ] +extend-ignore = [ + "PLW2901", "PLR2004", # From Pylint plugin, not enabled by default + "PLR0912", # Already covered: mccabe (C90) +] [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] From 85838e45215ff3fd600d4e07454e95e5c2cb40fc Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 24 Feb 2024 14:03:39 -0300 Subject: [PATCH 61/72] feat(LSP): Delete unnecessary line in configs The deleted line was already commented out. There is no need for the line anyways as the mccabe plugin comes already disabled by default. Furthermore the option is a duplication, enabling the plugin and setting a value to the `threshold` has the same effect as setting the `maxComplexity` value on Flake8's plugin. The only distinction is McCabe came, when enabled, with a default preset value of 15 for `threshold`, which Flake8 hasn't for `maxComplexity`. --- nvim/lua/lsp/server_settings/pylsp.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index de2a3f6..3a0e19a 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -7,7 +7,6 @@ local pylsp_settings = { pylsp_mypy = { enabled = true }, pycodestyle = { enabled = false }, -- covered in flake8 pyflakes = { enabled = false }, -- covered in flake8 - -- mccabe = { enabled = false }, -- not covered in flake8 by default; PyLSP doesn't handle the option }, } From 1493b3ceb5b1614b7ef797736a69cce65b6c7f0b Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 24 Feb 2024 20:37:50 -0300 Subject: [PATCH 62/72] feat(LSP): Move some comments between config files Some Pylint settings that are more probable to occur on medium-big projects were move to the pyproject.toml template, in order to have it near when a new project is started. On the other hand, those checks were never going to be on for regular Python programming. --- pylintrc.toml | 1 - templates/pyproject.toml | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pylintrc.toml b/pylintrc.toml index c862ef9..b60ffac 100644 --- a/pylintrc.toml +++ b/pylintrc.toml @@ -15,5 +15,4 @@ disable = [ # other stuff # Unfold "missing-docstring" (https://pylint.rtfd.io/en/latest/user_guide/messages/convention/missing-docstring.html) "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", - #"invalid-name", "redefined-outer-name", "logging-format-interpolation", ] diff --git a/templates/pyproject.toml b/templates/pyproject.toml index 254a5b7..63078db 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -33,6 +33,9 @@ disable = [ # other stuff "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", + #"logging-format-interpolation", + #"redefined-outer-name", # Pytest fixtures in tests + #"invalid-name", # Class-attributes in Django-commands (.help) ] [tool.mypy] From 41115cdd19acdf6fc98b10230f738f2b535c4d2d Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sun, 25 Feb 2024 23:00:39 -0300 Subject: [PATCH 63/72] feat(LSP): Override pretty flag for Mypy As the `--pretty` flat for Mypy provides nicer output, the soft word wrap it uses makes editors receive part of the message. Hence the setting has to be overridden inside editors (the flag is kept on because invoking Mypy from terminal benefits from the extra output information). --- emacs/init.el | 2 +- nvim/lua/lsp/server_settings/pylsp.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 555cfc4..09c803d 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -20,7 +20,7 @@ :flake8 (:enabled t) :pylint (:enabled t :executable "pylint") - :pylsp_mypy (:enabled t) + :pylsp_mypy (:overrides [t "--no-pretty"]) :pycodestyle (:enabled :json-false) :pyflakes (:enabled :json-false))))) (when window-system (set-frame-size (selected-frame) 85 60)) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index 3a0e19a..8ab62b0 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -4,7 +4,7 @@ local pylsp_settings = { ruff = { enabled = true }, -- Settings come from $XDG_CONFIG_HOME/ruff/ruff.toml flake8 = { enabled = true }, pylint = { enabled = true }, - pylsp_mypy = { enabled = true }, + pylsp_mypy = { overrides = { true, "--no-pretty" } }, pycodestyle = { enabled = false }, -- covered in flake8 pyflakes = { enabled = false }, -- covered in flake8 }, From d89fbb2f403017e2932c5a972d23cf429382e3d2 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 26 Feb 2024 10:00:09 -0300 Subject: [PATCH 64/72] feat(LSP): Reorganise PyLSP blocks of code Although the block of code moved is programmatic configuration taking place before the actual on/off of settings (which could be interpreted as metadata config), the block of code in question had nothing to do with the setting of other LSPs than PyLSP. The whole block is for pre-installing plugins for PyLSP server, or its plugins'. --- nvim/lua/lsp/server_settings/init.lua | 26 -------------------------- nvim/lua/lsp/server_settings/pylsp.lua | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/nvim/lua/lsp/server_settings/init.lua b/nvim/lua/lsp/server_settings/init.lua index fbf33d4..2f9d42a 100644 --- a/nvim/lua/lsp/server_settings/init.lua +++ b/nvim/lua/lsp/server_settings/init.lua @@ -1,29 +1,3 @@ ---if vim.fn.exists(":PylspInstall") then --- vim.cmd("PylspInstall pylsp-mypy") ---end --- https://github.com/williamboman/mason.nvim/discussions/908 -local pylsp = require("mason-registry").get_package("python-lsp-server") -pylsp:on("install:success", function () - local mason_package_path = function(package) - local path = vim.fn.resolve(vim.fn.stdpath("data") .. "/mason/packages/" .. package) - return path - end - - local path = mason_package_path("python-lsp-server") - local command = path .. "/venv/bin/python" - - local install_cmd = { command, "-m", "pip", "install" } - local pylsp_plugins = { "python-lsp-ruff", "pylsp-mypy" } - vim.schedule(function() - vim.fn.system(vim.list_extend(install_cmd, pylsp_plugins)) - end) - - local flake8_plugins = { "flake8-pyproject", "flake8-pylint" } - vim.schedule(function() - vim.fn.system(vim.list_extend(install_cmd, flake8_plugins)) - end) -end) - local opts = {} opts.pylsp = require("lsp.server_settings.pylsp") opts.hls = require("lsp.server_settings.hls") diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index 8ab62b0..f434582 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -1,3 +1,29 @@ +--if vim.fn.exists(":PylspInstall") then +-- vim.cmd("PylspInstall pylsp-mypy") +--end +-- https://github.com/williamboman/mason.nvim/discussions/908 +local pylsp = require("mason-registry").get_package("python-lsp-server") +pylsp:on("install:success", function () + local mason_package_path = function(package) + local path = vim.fn.resolve(vim.fn.stdpath("data") .. "/mason/packages/" .. package) + return path + end + + local path = mason_package_path("python-lsp-server") + local command = path .. "/venv/bin/python" + + local install_cmd = { command, "-m", "pip", "install" } + local pylsp_plugins = { "python-lsp-ruff", "pylsp-mypy" } + vim.schedule(function() + vim.fn.system(vim.list_extend(install_cmd, pylsp_plugins)) + end) + + local flake8_plugins = { "flake8-pyproject", "flake8-pylint" } + vim.schedule(function() + vim.fn.system(vim.list_extend(install_cmd, flake8_plugins)) + end) +end) + local pylsp_settings = { configurationSources = { "flake8" }, -- tool's config files to override settings from plugins = { From 695f0977d6c375d9ef17f05c1f35b824557184b9 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 26 Feb 2024 11:18:36 -0300 Subject: [PATCH 65/72] feat(templates): Add new python hook for pre-commit For the pre-commit-config.yaml added the Ruff hook and, as Ruff is being configured via TOML file instead of inline command line arguments, also added the toml checker. --- templates/_pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/_pre-commit-config.yaml b/templates/_pre-commit-config.yaml index d2bffc6..6fa6313 100644 --- a/templates/_pre-commit-config.yaml +++ b/templates/_pre-commit-config.yaml @@ -4,10 +4,17 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer + - id: check-toml - id: check-yaml exclude: .chart/ - id: check-added-large-files +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.2 + hooks: + - id: ruff + args: [--config=./backoffice/ceg/pyproject.toml] + - repo: https://github.com/PyCQA/flake8 rev: 7.0.0 hooks: From 5d6c98a528ef942a2828ebecdbbc665bf3efa2cb Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 26 Feb 2024 11:22:07 -0300 Subject: [PATCH 66/72] feat(templates): Reorganise some hook's arguments Some of the arguments in the pip-tools hook were for an older version of the hook, which didn't work with pyproject.toml files. Since Python 3.6 is long deprecated now, the template is being bumped at least to the 3.7 version. --- templates/_pre-commit-config.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/templates/_pre-commit-config.yaml b/templates/_pre-commit-config.yaml index 6fa6313..cc4b626 100644 --- a/templates/_pre-commit-config.yaml +++ b/templates/_pre-commit-config.yaml @@ -54,7 +54,7 @@ repos: hooks: - id: pyupgrade args: [--py311-plus] - args: [--py36-plus] + args: [--py37-plus] - repo: https://github.com/pycqa/isort rev: 5.13.2 @@ -62,23 +62,20 @@ repos: - id: isort name: isort (python) args: [--check-only, --line-length=120, --diff] - args: [--check-only, --profile=django, --line-length=120, --diff, --py=36, --src=ceg/] + args: [--check-only, --profile=django, --line-length=120, --diff, --py=37, --src=ceg/] - repo: https://github.com/jazzband/pip-tools rev: 7.3.0 hooks: - id: pip-compile - name: pip-compile setup.py - files: ^(setup\.py|requirements\.txt)$ + name: pip-compile requirements.txt + files: ^requirements\.(in|txt)$ + args: [requirements.txt] - id: pip-compile name: pip-compile requirements-dev.in - args: [requirements-dev.in] files: ^requirements-dev\.(in|txt)$ + args: [requirements-dev.in] - id: pip-compile name: pip-compile requirements-lint.in - args: [requirements-lint.in] files: ^requirements-lint\.(in|txt)$ - - id: pip-compile - name: pip-compile requirements.txt - args: [requirements.txt] - files: ^requirements\.(in|txt)$ + args: [requirements-lint.in] From bd435b7730f1148ae2051814093518b35741bf35 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 26 Feb 2024 11:32:51 -0300 Subject: [PATCH 67/72] feat(template): Make pre-commit hooks read configs from config files When possible, for pre-commit hooks, instead of receiving arguments via command line, make them read their config from a configuration file to achieve the same behavior as invoking the corresponding tool outside pre-commit. --- templates/_pre-commit-config.yaml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/templates/_pre-commit-config.yaml b/templates/_pre-commit-config.yaml index cc4b626..c71506c 100644 --- a/templates/_pre-commit-config.yaml +++ b/templates/_pre-commit-config.yaml @@ -19,19 +19,15 @@ repos: rev: 7.0.0 hooks: - id: flake8 - args: [--max-line-length=120] + args: [--toml-config=./pyproject.toml] + additional_dependencies: [Flake8-pyproject] language: system # don't commit!! - repo: https://github.com/PyCQA/pylint rev: v3.0.3 hooks: - id: pylint - args: [ - --max-line-length=120, - "--disable=missing-docstring,invalid-name,redefined-outer-name,logging-format-interpolation,too-many-ancestors,too-few-public-methods", - --disable=import-error, - --max-args=7, - ] + args: [--rcfile=./pyproject.toml] # disabled plugins: pylint.extensions.mccabe exclude: tests|tests/input|tests/extensions/data|tests/regrtest_data|tests/data|doc language: system # don't commit!! @@ -40,11 +36,7 @@ repos: rev: v1.8.0 hooks: - id: mypy - args: [ - --ignore-missing-imports, - --follow-imports=silent, - --show-column-numbers, - ] + args: [--show-column-numbers, --pretty, --ignore-missing-imports, --follow-imports=silent] additional_dependencies: [types-all] #exclude: migrations/ language: system # don't commit!! From fe8b7b02380593f56f7708ebc31a4d379701b2ca Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 26 Feb 2024 12:43:53 -0300 Subject: [PATCH 68/72] feat(LSP): Delete unnecessary settings Third-party installed plugins are enabled by default, hence there is no need to explicitly enable it. Ruff plugin doesn't come with standard PyLSP, and is one (along with pylsp-mypy) of the manually added plugins. --- emacs/init.el | 3 +-- nvim/lua/lsp/server_settings/pylsp.lua | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 09c803d..47b3345 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -16,8 +16,7 @@ (add-hook 'prog-mode-hook 'eglot-ensure) ; Requires LSP servers in PATH (setq-default eglot-workspace-configuration '(:pylsp (:configurationSources ["flake8"] - :plugins (:ruff (:enabled t) - :flake8 (:enabled t) + :plugins (:flake8 (:enabled t) :pylint (:enabled t :executable "pylint") :pylsp_mypy (:overrides [t "--no-pretty"]) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index f434582..c613e99 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -27,7 +27,6 @@ end) local pylsp_settings = { configurationSources = { "flake8" }, -- tool's config files to override settings from plugins = { - ruff = { enabled = true }, -- Settings come from $XDG_CONFIG_HOME/ruff/ruff.toml flake8 = { enabled = true }, pylint = { enabled = true }, pylsp_mypy = { overrides = { true, "--no-pretty" } }, From 8418e533278e472f91108ce1ae104c4d6bfd6cfc Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 2 Mar 2024 17:00:09 -0300 Subject: [PATCH 69/72] feat(LSP): Change default python executable On most Linux distros python3 is the default, even more, there is no Python version 2 to be installed anyways, hence there is no need to distinguish which python version to load anymore. The default python executable has come to be `python` even though the Python version is 3.x. Furthermore, on all virtual environments `python` exists and is linked to point to a Python 3.x executable. --- nvim/lua/lsp/server_settings/pylsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index c613e99..af23e86 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -36,7 +36,7 @@ local pylsp_settings = { } local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";") -local python_exec = vim.fn.findfile("python3", venv_dir .. "/bin;") +local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;") if venv_dir ~= "" and python_exec ~= "" then pylsp_settings.plugins.jedi = {environment = python_exec} end From 8d626d21881b1726f9f915b252f5d278ad44fa9b Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 2 Mar 2024 17:17:53 -0300 Subject: [PATCH 70/72] feat(LSP): Refactor alternative executables for linters Test for new executables, for different checkers, for Python LSP only if the virtual environment directory has been found. The previous behavior could have found executables for such linters on different places, as they could have been appearing outside a virtual environment directory (if the `venv_dir` variable tested as an empty string). Such behavior could lead to undefined behaviors. --- nvim/lua/lsp/server_settings/pylsp.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index af23e86..8ac47b3 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -36,21 +36,23 @@ local pylsp_settings = { } local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";") -local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;") -if venv_dir ~= "" and python_exec ~= "" then +if venv_dir ~= "" then + local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;") + if python_exec ~= "" then pylsp_settings.plugins.jedi = {environment = python_exec} -end -local flake8_exec = vim.fn.findfile("flake8", venv_dir .. "/bin;") -if flake8_exec ~= "" then + end + local flake8_exec = vim.fn.findfile("flake8", venv_dir .. "/bin;") + if flake8_exec ~= "" then pylsp_settings.plugins.flake8.executable = flake8_exec -end -local pylint_exec = vim.fn.findfile("pylint", venv_dir .. "/bin;") -if pylint_exec ~= "" then + end + local pylint_exec = vim.fn.findfile("pylint", venv_dir .. "/bin;") + if pylint_exec ~= "" then pylsp_settings.plugins.pylint.executable = pylint_exec -end -local mypy_exec = vim.fn.findfile("mypy", venv_dir .. "/bin;") -if mypy_exec ~= "" or python_exec ~= "" then + end + local mypy_exec = vim.fn.findfile("mypy", venv_dir .. "/bin;") + if mypy_exec ~= "" or python_exec ~= "" then pylsp_settings.plugins.pylsp_mypy.overrides = {"--python-executable", python_exec, true} + end end return { settings = { pylsp = pylsp_settings } } From b15b9178c626a0538988dbcaf3d612665a35a1fd Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Sat, 2 Mar 2024 17:29:42 -0300 Subject: [PATCH 71/72] feat(LSP): Modify the way a virtual env is located Changed the hard-coded virtual environment directory name used to look for Python related binaries to whatever directory is defined in the `VIRTUAL_ENV` environment variable. That variable's value is more reliable, even more when Python virtual environments are located in a central location, not near the repository. --- nvim/lua/lsp/server_settings/pylsp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvim/lua/lsp/server_settings/pylsp.lua b/nvim/lua/lsp/server_settings/pylsp.lua index 8ac47b3..c11a909 100644 --- a/nvim/lua/lsp/server_settings/pylsp.lua +++ b/nvim/lua/lsp/server_settings/pylsp.lua @@ -35,8 +35,8 @@ local pylsp_settings = { }, } -local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";") -if venv_dir ~= "" then +local venv_dir = vim.env.VIRTUAL_ENV +if venv_dir ~= nil then local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;") if python_exec ~= "" then pylsp_settings.plugins.jedi = {environment = python_exec} From 3b4ddd41ba8d2900170f7f755863c5a6b57630bd Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Wed, 20 Mar 2024 22:53:57 -0300 Subject: [PATCH 72/72] fix(treesitter): Correct query override for Python classes The override in place for Python classes highlighting wasn't having effect. The issue is that now user queries need to explicitly extend, with the keyword `;extend` the scheme rules they are overriding. --- nvim/after/queries/python/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvim/after/queries/python/highlights.scm b/nvim/after/queries/python/highlights.scm index e055c6d..942d78a 100644 --- a/nvim/after/queries/python/highlights.scm +++ b/nvim/after/queries/python/highlights.scm @@ -1,3 +1,5 @@ +; extends + ; Correct coloring group for class keyword: ; https://github.com/nvim-treesitter/nvim-treesitter/pull/3177#issuecomment-1186027468 "class" @keyword.function