From fa29851e3f12d5e3634f201212b5c2e16e28742b Mon Sep 17 00:00:00 2001 From: SafetyMary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 3 Aug 2024 01:29:09 +0800 Subject: [PATCH 01/37] Initial settings --- TODO.md | 24 ++++++++++++++++++++++++ init.lua | 2 +- lua/kickstart/plugins/lspconfig.lua | 2 ++ lua/options.lua | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000000..96ee5981cb9 --- /dev/null +++ b/TODO.md @@ -0,0 +1,24 @@ +# TODO items + +- Major issues: + - Disable autoformat on save + - Share terminal and system clipbaord + +- Minor issues: + - Fix pyright pyspark issue + - Allow usage/inheritance tracking + +- Miscellaneous issues: + - Set character limit to 120 (same as pycharm) + - Add visual guide to 120 character limit + - Add highlight support for line diff for git commit and merge requests + - Add spelling check + - Allow commenting multiple lines + - Allow indenting/unindenting multiple lines + - Allow multiple tabs + - Add file tree view + - Make LSP errors/warnings appear on next line + - Allow highlighting and moving the line (like hightlight with 'shift'+'ctrl'+up/down arrow key) + - Figure out a better way for autocomplete navigation and selection + - Fix TODO highlight in docstring + diff --git a/init.lua b/init.lua index 3784c1a18c9..6c6d42bd327 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] require 'options' diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index b9c3c623c76..e031d67feaf 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -209,6 +209,8 @@ return { local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'pyright', + -- 'ruff', todo: need to fix auto format on write }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/lua/options.lua b/lua/options.lua index 94ee2ed6364..bb843ad3641 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -7,7 +7,7 @@ vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' From 62f4a32f42bb203602c4772ed8c7fd0c4ea0918d Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:55:20 +0800 Subject: [PATCH 02/37] Add manual format command --- lua/kickstart/plugins/conform.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 6883db52cf7..f80c388dea8 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -1,3 +1,17 @@ +-- Add format command +vim.api.nvim_create_user_command('Format', function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ['end'] = { args.line2, end_line:len() }, + } + end + require('conform').format { async = true, lsp_format = 'fallback', range = range } +end, { range = true }) + +-- kickstart config return { { -- Autoformat 'stevearc/conform.nvim', From f521b16adbc0e64155a3498343cbf0cdfddcd728 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 3 Aug 2024 00:54:41 +0800 Subject: [PATCH 03/37] Now default to no autoformat on write --- TODO.md | 1 - lua/kickstart/plugins/conform.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 96ee5981cb9..6800bd30a54 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO items - Major issues: - - Disable autoformat on save - Share terminal and system clipbaord - Minor issues: diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index f80c388dea8..19be9a5fa7d 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -11,6 +11,25 @@ vim.api.nvim_create_user_command('Format', function(args) require('conform').format { async = true, lsp_format = 'fallback', range = range } end, { range = true }) +-- Add toggle command to format-on-save +vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end +end, { + desc = 'Disable autoformat-on-save', + bang = true, +}) +vim.api.nvim_create_user_command('FormatEnable', function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false +end, { + desc = 'Re-enable autoformat-on-save', +}) + -- kickstart config return { { -- Autoformat @@ -30,6 +49,14 @@ return { opts = { notify_on_error = false, format_on_save = function(bufnr) + -- Define default behaviour here (default disable autoformat) + if (vim.g.disable_autoformat == nil) or (vim.b[bufnr].disable_autoformat == nil) then + return + end + -- Disable autoformat with a global or buffer-local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. From e728df110f7a70b72866bc6f13e13cfe0df6c13d Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 4 Aug 2024 20:39:50 +0800 Subject: [PATCH 04/37] add todo --- TODO.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.md b/TODO.md index 6800bd30a54..3fc06cc1e19 100644 --- a/TODO.md +++ b/TODO.md @@ -6,6 +6,8 @@ - Minor issues: - Fix pyright pyspark issue - Allow usage/inheritance tracking + - Add and config python formater + - Add and config SQL formater - Miscellaneous issues: - Set character limit to 120 (same as pycharm) From 34067ca44f3b7c0c196d1fe576a1e4e4c83bc559 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:57:47 +0800 Subject: [PATCH 05/37] add ruff in mason and state ruff as python formater in conform --- TODO.md | 8 +++++--- lua/kickstart/plugins/conform.lua | 1 + lua/kickstart/plugins/lspconfig.lua | 2 +- private_changes.md | 13 +++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 private_changes.md diff --git a/TODO.md b/TODO.md index 3fc06cc1e19..e2ca33da399 100644 --- a/TODO.md +++ b/TODO.md @@ -6,12 +6,14 @@ - Minor issues: - Fix pyright pyspark issue - Allow usage/inheritance tracking - - Add and config python formater - Add and config SQL formater + - Add and config markdown formater - Miscellaneous issues: - - Set character limit to 120 (same as pycharm) - - Add visual guide to 120 character limit + - Formater character limit + - set LSP warning for lines exceeding character limit + - Set character limit to 120 (same as pycharm) + - Add visual guide to 120 character limit - Add highlight support for line diff for git commit and merge requests - Add spelling check - Allow commenting multiple lines diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 19be9a5fa7d..88ea25da527 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -74,6 +74,7 @@ return { end, formatters_by_ft = { lua = { 'stylua' }, + python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index e031d67feaf..43b7ade3975 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -210,7 +210,7 @@ return { vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code 'pyright', - -- 'ruff', todo: need to fix auto format on write + 'ruff', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/private_changes.md b/private_changes.md new file mode 100644 index 00000000000..8cef4849b4e --- /dev/null +++ b/private_changes.md @@ -0,0 +1,13 @@ +# Private changes +- LSP + - pyright + +- Conform + - Add 'Format' command for manual formater trigger + - Add 'FormatEnable' and 'FormatDisable' toggling format on write + - Default disable format on write + - Add ruff_fix/ruff_format/ruff_organize_imports as python formater + +- Miscellaneous changes + - JetbrainsMonoNL Nerd Font Mono + - Relative line number From 649fd453330b60a98e1046ce446ded4f1c5da701 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:54:52 +0800 Subject: [PATCH 06/37] fixed clipboard by installing xclip --- TODO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO.md b/TODO.md index e2ca33da399..521816564fc 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO items - Major issues: - - Share terminal and system clipbaord - Minor issues: - Fix pyright pyspark issue From 4992e8d9cd76821db190af1a443c2fa8bfcb56ff Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:41:30 +0800 Subject: [PATCH 07/37] add sql formater --- TODO.md | 16 +++++++++------- lua/kickstart/plugins/conform.lua | 1 + lua/kickstart/plugins/lspconfig.lua | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index 521816564fc..828761db207 100644 --- a/TODO.md +++ b/TODO.md @@ -1,12 +1,18 @@ # TODO items - Major issues: + - Add file tree view + - Configure telescope/harpoon for use - Minor issues: - Fix pyright pyspark issue - Allow usage/inheritance tracking - - Add and config SQL formater - Add and config markdown formater + - Make LSP errors/warnings appear on next line + - Allow multiple tabs + - Add spelling check + - Allow indenting/unindenting multiple lines + - Allow commenting multiple lines - Miscellaneous issues: - Formater character limit @@ -14,13 +20,9 @@ - Set character limit to 120 (same as pycharm) - Add visual guide to 120 character limit - Add highlight support for line diff for git commit and merge requests - - Add spelling check - - Allow commenting multiple lines - - Allow indenting/unindenting multiple lines - - Allow multiple tabs - - Add file tree view - - Make LSP errors/warnings appear on next line - Allow highlighting and moving the line (like hightlight with 'shift'+'ctrl'+up/down arrow key) - Figure out a better way for autocomplete navigation and selection - Fix TODO highlight in docstring +- Nice to have + - SQL LSP through local dll files diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 88ea25da527..e7f50f83ee8 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -75,6 +75,7 @@ return { formatters_by_ft = { lua = { 'stylua' }, python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, + sql = { 'sqlfluff' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 43b7ade3975..84d5bba10d7 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -211,6 +211,7 @@ return { 'stylua', -- Used to format Lua code 'pyright', 'ruff', + 'sqlfluff', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } From db902ce7f712a6009b5445c558318a226b2926b6 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:37:22 +0800 Subject: [PATCH 08/37] update docs --- TODO.md | 3 +++ private_changes.md | 1 + 2 files changed, 4 insertions(+) diff --git a/TODO.md b/TODO.md index 828761db207..6f3c108e1db 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,8 @@ - Add spelling check - Allow indenting/unindenting multiple lines - Allow commenting multiple lines + - Allow find all within project scope + - Add auto close brackets - Miscellaneous issues: - Formater character limit @@ -26,3 +28,4 @@ - Nice to have - SQL LSP through local dll files + - Go through LazyVim language setup for python/SQL/md diff --git a/private_changes.md b/private_changes.md index 8cef4849b4e..e05945eddbc 100644 --- a/private_changes.md +++ b/private_changes.md @@ -7,6 +7,7 @@ - Add 'FormatEnable' and 'FormatDisable' toggling format on write - Default disable format on write - Add ruff_fix/ruff_format/ruff_organize_imports as python formater + - Add sqlfluff as SQL formater - Miscellaneous changes - JetbrainsMonoNL Nerd Font Mono From 523276625cc3e7b34d5958b50a8f1215e354ae02 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 7 Aug 2024 00:19:57 +0800 Subject: [PATCH 09/37] add markdownlint-cli2 and markdown-toc for md file formating --- lua/kickstart/plugins/conform.lua | 1 + lua/kickstart/plugins/lspconfig.lua | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index e7f50f83ee8..d8979a82a70 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -76,6 +76,7 @@ return { lua = { 'stylua' }, python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, sql = { 'sqlfluff' }, + markdown = { 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 84d5bba10d7..f47a5fd8d01 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -212,6 +212,8 @@ return { 'pyright', 'ruff', 'sqlfluff', + 'markdownlint-cli2', + 'markdown-toc', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } From aaebf313d08d5c4a7bc68b6fc7a6177270e16566 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:10:37 +0800 Subject: [PATCH 10/37] update TODO --- TODO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO.md b/TODO.md index 6f3c108e1db..d7c2503d877 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,6 @@ - Minor issues: - Fix pyright pyspark issue - Allow usage/inheritance tracking - - Add and config markdown formater - Make LSP errors/warnings appear on next line - Allow multiple tabs - Add spelling check From 5743988af215e54e4476d13aecd61ff75a3ace6a Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:18:31 +0800 Subject: [PATCH 11/37] add prettier as additional md formatter --- lua/kickstart/plugins/conform.lua | 2 +- lua/kickstart/plugins/lspconfig.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index d8979a82a70..3c83fed951c 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -76,7 +76,7 @@ return { lua = { 'stylua' }, python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, sql = { 'sqlfluff' }, - markdown = { 'markdown-toc', 'markdownlint-cli2' }, + markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index f47a5fd8d01..9398feae383 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -212,6 +212,7 @@ return { 'pyright', 'ruff', 'sqlfluff', + 'prettier', 'markdownlint-cli2', 'markdown-toc', }) From 205615817f841e60e14b340fa4958ec04b080225 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:52:03 +0800 Subject: [PATCH 12/37] set up ruff formatter --- lua/kickstart/plugins/conform.lua | 4 +++- lua/kickstart/plugins/lspconfig.lua | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 3c83fed951c..f4fcbc50eea 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -74,7 +74,9 @@ return { end, formatters_by_ft = { lua = { 'stylua' }, - python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, + -- use ruff as formatter, conform with 'ruff_format' uses ruff binary and ignores server settings/configs + -- https://github.com/astral-sh/ruff/issues/12778 + python = { lsp_format = 'first' }, -- force confom to use ruff lsp server sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 9398feae383..44feb1569e8 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -180,6 +180,17 @@ return { -- tsserver = {}, -- + -- Override ruff formatter settings here + ruff = { + init_options = { + settings = { + lineLength = 120, + organizeImports = true, + fixAll = true, -- not sure if this replaces ruff_fix + }, + }, + }, + lua_ls = { -- cmd = {...}, -- filetypes = { ...}, From dee2b025c4a63378910f1fd7ceb11b39d0fa5081 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:08:25 +0800 Subject: [PATCH 13/37] Update todo --- TODO.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index d7c2503d877..43b5e2b50de 100644 --- a/TODO.md +++ b/TODO.md @@ -1,24 +1,32 @@ # TODO items - Major issues: + - Add file tree view - Configure telescope/harpoon for use + - Refactoring support + - Jump to usage/source support - Minor issues: + - Fix pyright pyspark issue - Allow usage/inheritance tracking - Make LSP errors/warnings appear on next line + - Implement vim.diagnostic.open_float() - Allow multiple tabs - Add spelling check - Allow indenting/unindenting multiple lines - Allow commenting multiple lines - Allow find all within project scope - Add auto close brackets + - Set up LSP and formatter for bash script + - shfmt, shellcheck, bash LSP + - Add preview capability for markdown files - Miscellaneous issues: + - Formater character limit - - set LSP warning for lines exceeding character limit - - Set character limit to 120 (same as pycharm) + - Set LSP warning for lines exceeding character limit - Add visual guide to 120 character limit - Add highlight support for line diff for git commit and merge requests - Allow highlighting and moving the line (like hightlight with 'shift'+'ctrl'+up/down arrow key) From d404a1a6d20f57b54713fd8b3d106b7f4d3160eb Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 14 Aug 2024 11:19:04 +0800 Subject: [PATCH 14/37] try making telescope into vertical mode --- TODO.md | 2 +- lua/kickstart/plugins/telescope.lua | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 43b5e2b50de..702420cb75d 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ - Major issues: - Add file tree view - - Configure telescope/harpoon for use - Refactoring support - Jump to usage/source support @@ -22,6 +21,7 @@ - Set up LSP and formatter for bash script - shfmt, shellcheck, bash LSP - Add preview capability for markdown files + - Configure telescope/harpoon for use - Miscellaneous issues: diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index 159971f00e7..7af313bf9ed 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -61,6 +61,15 @@ return { -- i = { [''] = 'to_fuzzy_refine' }, -- }, -- }, + + -- set vertical file preview + defaults = { + layout_strategy = 'vertical', + layout_config = { + vertical = { width = 0.8 }, + }, + }, + -- pickers = {} extensions = { ['ui-select'] = { From 8f3831ba8668ea1bbfda2a91f33fe76772c84a2a Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:40:59 +0800 Subject: [PATCH 15/37] add back ruff fix and organize imports --- lua/kickstart/plugins/conform.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index f4fcbc50eea..207e7eb063e 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -76,7 +76,9 @@ return { lua = { 'stylua' }, -- use ruff as formatter, conform with 'ruff_format' uses ruff binary and ignores server settings/configs -- https://github.com/astral-sh/ruff/issues/12778 - python = { lsp_format = 'first' }, -- force confom to use ruff lsp server + -- currently ruff_organize_imports uses linter rather than formater, a unified interface is planned + -- https://github.com/astral-sh/ruff/issues/8232 + python = { 'ruff_fix', 'ruff_organize_imports', lsp_format = 'first' }, -- force confom to use ruff lsp server sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially From 0a95f11cb692283079c756b3434e0f06e5d20cb9 Mon Sep 17 00:00:00 2001 From: SafetyMary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:11:37 +0800 Subject: [PATCH 16/37] Revert "add back ruff fix and organize imports" --- lua/kickstart/plugins/conform.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 207e7eb063e..f4fcbc50eea 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -76,9 +76,7 @@ return { lua = { 'stylua' }, -- use ruff as formatter, conform with 'ruff_format' uses ruff binary and ignores server settings/configs -- https://github.com/astral-sh/ruff/issues/12778 - -- currently ruff_organize_imports uses linter rather than formater, a unified interface is planned - -- https://github.com/astral-sh/ruff/issues/8232 - python = { 'ruff_fix', 'ruff_organize_imports', lsp_format = 'first' }, -- force confom to use ruff lsp server + python = { lsp_format = 'first' }, -- force confom to use ruff lsp server sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially From d67bb470d20c2d933f25e44dad02345e5b3b9c84 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Thu, 15 Aug 2024 09:58:24 +0800 Subject: [PATCH 17/37] fix ruff organize improts --- lua/kickstart/plugins/conform.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index f4fcbc50eea..b6757b81339 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -76,7 +76,9 @@ return { lua = { 'stylua' }, -- use ruff as formatter, conform with 'ruff_format' uses ruff binary and ignores server settings/configs -- https://github.com/astral-sh/ruff/issues/12778 - python = { lsp_format = 'first' }, -- force confom to use ruff lsp server + -- currently ruff_organize_imports uses linter rather than formater, a unified interface is planned + -- https://github.com/astral-sh/ruff/issues/8232 + python = { 'ruff_fix', 'ruff_organize_imports', lsp_format = 'prefer' }, -- force confom to use ruff lsp server sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially From f992a4ced131940591edae6e38a122f63fde978f Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:49:18 +0800 Subject: [PATCH 18/37] fix ruff oranize imports again --- lua/kickstart/plugins/conform.lua | 4 +++- lua/kickstart/plugins/lspconfig.lua | 11 ----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index b6757b81339..309063a37b6 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -8,6 +8,8 @@ vim.api.nvim_create_user_command('Format', function(args) ['end'] = { args.line2, end_line:len() }, } end + -- Use CLI args instead of LSP server settings + require('conform').formatters.ruff_format = { append_args = { '--line-length', '120' } } require('conform').format { async = true, lsp_format = 'fallback', range = range } end, { range = true }) @@ -78,7 +80,7 @@ return { -- https://github.com/astral-sh/ruff/issues/12778 -- currently ruff_organize_imports uses linter rather than formater, a unified interface is planned -- https://github.com/astral-sh/ruff/issues/8232 - python = { 'ruff_fix', 'ruff_organize_imports', lsp_format = 'prefer' }, -- force confom to use ruff lsp server + python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, -- Conform can also run multiple formatters sequentially diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 44feb1569e8..9398feae383 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -180,17 +180,6 @@ return { -- tsserver = {}, -- - -- Override ruff formatter settings here - ruff = { - init_options = { - settings = { - lineLength = 120, - organizeImports = true, - fixAll = true, -- not sure if this replaces ruff_fix - }, - }, - }, - lua_ls = { -- cmd = {...}, -- filetypes = { ...}, From 87f7fba954a3b1efbac2c7010a792be0f9004721 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:00:33 +0800 Subject: [PATCH 19/37] replace pyright with pylsp and mypy --- TODO.md | 13 ++++------ lua/custom/plugins/init.lua | 40 ++++++++++++++++++++++++++++- lua/kickstart/plugins/lint.lua | 3 ++- lua/kickstart/plugins/lspconfig.lua | 29 ++++++++++++++++++++- lua/lazy-plugins.lua | 4 +-- 5 files changed, 76 insertions(+), 13 deletions(-) diff --git a/TODO.md b/TODO.md index 702420cb75d..f59182a16a5 100644 --- a/TODO.md +++ b/TODO.md @@ -2,26 +2,22 @@ - Major issues: - - Add file tree view - - Refactoring support - - Jump to usage/source support + - Checking for unused function args + - No check for classmethod vs abstractmethod sequence - Minor issues: - - Fix pyright pyspark issue - Allow usage/inheritance tracking - Make LSP errors/warnings appear on next line - Implement vim.diagnostic.open_float() - - Allow multiple tabs - Add spelling check - Allow indenting/unindenting multiple lines - Allow commenting multiple lines - - Allow find all within project scope - Add auto close brackets - Set up LSP and formatter for bash script - shfmt, shellcheck, bash LSP - Add preview capability for markdown files - - Configure telescope/harpoon for use + - Add json formatter - Miscellaneous issues: @@ -29,7 +25,8 @@ - Set LSP warning for lines exceeding character limit - Add visual guide to 120 character limit - Add highlight support for line diff for git commit and merge requests - - Allow highlighting and moving the line (like hightlight with 'shift'+'ctrl'+up/down arrow key) + - Allow highlighting and moving the line + (like hightlight with 'shift'+'ctrl'+up/down arrow key) - Figure out a better way for autocomplete navigation and selection - Fix TODO highlight in docstring diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..f3e15034aef 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,42 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'folke/trouble.nvim', + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = 'Trouble', + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', + }, + }, + }, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index ca9bc237904..bf9a9d28671 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -6,7 +6,8 @@ return { config = function() local lint = require 'lint' lint.linters_by_ft = { - markdown = { 'markdownlint' }, + markdown = { 'markdownlint-cli2' }, + python = { 'mypy', 'ruff' }, } -- To allow other plugins to add linters to require('lint').linters_by_ft, diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 9398feae383..186c51bb58b 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -180,6 +180,32 @@ return { -- tsserver = {}, -- + pylsp = { + settings = { + pylsp = { + plugins = { + pycodestyle = { + enabled = true, + maxLineLength = 120, + }, + pyflakes = { + enabled = false, + }, + flake8 = { + enabled = false, + maxLineLength = 120, -- seems flake8 takes over pycodestyle + }, + pylint = { + enabled = false, + maxLineLength = 120, + }, + }, + }, + }, + }, + + mypy = {}, + lua_ls = { -- cmd = {...}, -- filetypes = { ...}, @@ -209,7 +235,8 @@ return { local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code - 'pyright', + 'pylsp', + 'mypy', 'ruff', 'sqlfluff', 'prettier', diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index f601d395e2a..7e2570b99f9 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -55,7 +55,7 @@ require('lazy').setup({ -- -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', + require 'kickstart/plugins/lint', -- require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', @@ -64,7 +64,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the From ffb17ee5d37f7338fd72b10fd96a0962e457b230 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:43:40 +0800 Subject: [PATCH 20/37] remove mypy and linter, replace with a good pylsp setup --- lua/kickstart/plugins/lspconfig.lua | 33 ++++++++++++++++++----------- lua/lazy-plugins.lua | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 186c51bb58b..314c8378a13 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -180,32 +180,42 @@ return { -- tsserver = {}, -- + -- make sure to manually install jpylsp plugins + -- https://github.com/williamboman/mason-lspconfig.nvim/tree/main/lua/mason-lspconfig/server_configurations/pylsp pylsp = { settings = { pylsp = { plugins = { - pycodestyle = { + flake8 = { enabled = true, - maxLineLength = 120, + maxLineLength = 120, -- seems flake8 takes over pycodestyle }, - pyflakes = { - enabled = false, + pycodestyle = { + maxLineLength = 120, }, - flake8 = { - enabled = false, - maxLineLength = 120, -- seems flake8 takes over pycodestyle + pydocstyle = { + enabled = true, + convention = 'google', }, pylint = { - enabled = false, - maxLineLength = 120, + enabled = true, + args = { + '--max-line-length', + '120', + }, + }, + rope_autoimport = { + enabled = true, + }, + rope_completion = { + enabled = true, + eager = true, }, }, }, }, }, - mypy = {}, - lua_ls = { -- cmd = {...}, -- filetypes = { ...}, @@ -236,7 +246,6 @@ return { vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code 'pylsp', - 'mypy', 'ruff', 'sqlfluff', 'prettier', diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 7e2570b99f9..e483b64cd86 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -55,7 +55,7 @@ require('lazy').setup({ -- -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - require 'kickstart/plugins/lint', + -- require 'kickstart/plugins/lint', -- require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', From ce646875d2e63d80e8ea3a307498b42eef5e409d Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:38:14 +0800 Subject: [PATCH 21/37] use traditional auto completion keymaps and remove quick keymaps for windows nav --- lua/keymaps.lua | 8 ++++---- lua/kickstart/plugins/cmp.lua | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index c07a08a7514..ae72cbf5bc1 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -26,10 +26,10 @@ vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' } -- Use CTRL+ to switch between windows -- -- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` diff --git a/lua/kickstart/plugins/cmp.lua b/lua/kickstart/plugins/cmp.lua index e9ed483b75f..4026cb72450 100644 --- a/lua/kickstart/plugins/cmp.lua +++ b/lua/kickstart/plugins/cmp.lua @@ -70,9 +70,9 @@ return { -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display From 4e9e4e2f9dfff8d4781499691c9f5c4c7f287f41 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 31 Aug 2024 21:13:44 +0800 Subject: [PATCH 22/37] add pylsp install plugin commands and MasonToolsClean at VimEnter --- TODO.md | 6 +----- init.lua | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 51d1a74ff38..7b324140dca 100644 --- a/TODO.md +++ b/TODO.md @@ -2,31 +2,27 @@ - Major issues: - - Checking for unused function args - No check for classmethod vs abstractmethod sequence - Warn if a class method is static - Use LSP to rename/delete files - Minor issues: - - Allow usage/inheritance tracking - Make LSP errors/warnings appear on next line - Implement vim.diagnostic.open_float() - Add spelling check - Allow indenting/unindenting multiple lines - - Allow commenting multiple lines - Add auto close brackets - Set up LSP and formatter for bash script - shfmt, shellcheck, bash LSP - Add preview capability for markdown files - Add json formatter - leader f formating does not use current line length setting - - mypy does not check for function return type hint + - Auto detect vertical/horizontal monitor for telescope layout - Miscellaneous issues: - Formater character limit - - Set LSP warning for lines exceeding character limit - Add visual guide to 120 character limit - Add highlight support for line diff for git commit and merge requests - Allow highlighting and moving the line diff --git a/init.lua b/init.lua index 6c6d42bd327..c3024471387 100644 --- a/init.lua +++ b/init.lua @@ -105,5 +105,15 @@ require 'lazy-bootstrap' -- [[ Configure and install plugins ]] require 'lazy-plugins' +-- Run some neovim commands after setup +vim.api.nvim_create_autocmd('VimEnter', { + callback = function() + vim.cmd.PylspInstall { 'pyls-flake8' } + vim.cmd.PylspInstall { 'pyls-mypy' } + vim.cmd.PylspInstall { 'pylsp-rope' } + vim.cmd 'MasonToolsClean' + end, +}) + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et From 4eebb446478bc0d7bd1c9fd3f97857bd5c22e9a2 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:20:18 +0800 Subject: [PATCH 23/37] add todo --- TODO.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.md b/TODO.md index f59182a16a5..e39df4dd241 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,8 @@ - Checking for unused function args - No check for classmethod vs abstractmethod sequence + - Warn if a class method is static + - Use LSP to rename/delete files - Minor issues: @@ -29,6 +31,7 @@ (like hightlight with 'shift'+'ctrl'+up/down arrow key) - Figure out a better way for autocomplete navigation and selection - Fix TODO highlight in docstring + - Add Mason ensure uninstalled (for pyright) - Nice to have - SQL LSP through local dll files From 776437e67999a07f42fdfc555550bcfafe3c8962 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 31 Aug 2024 21:34:45 +0800 Subject: [PATCH 24/37] track lazy-lock --- .gitignore | 1 - lazy-lock.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 lazy-lock.json diff --git a/.gitignore b/.gitignore index 005b535b606..8a192cab54d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ test.sh nvim spell/ -lazy-lock.json diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..8a2c0941103 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,30 @@ +{ + "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "667102f26106709cddd2dff1f699610df5b94d7f" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3ed90180e70a6a50cd37ce7ecc3693bcdaa7b290" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "49e2699dc0d585b445eda24ed4bb45952ac20508" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lint": { "branch": "master", "commit": "debabca63c0905b59ce596a55a8e33eafdf66342" }, + "nvim-lspconfig": { "branch": "master", "commit": "037ea0901ce9a28cfcaa36302618f06d2e164fbf" }, + "nvim-treesitter": { "branch": "master", "commit": "bfb50de9cb0673a3bff620d881f690fb7e0d1328" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, + "tokyonight.nvim": { "branch": "main", "commit": "b0e7c7382a7e8f6456f2a95655983993ffda745e" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" } +} From 35ee6246f8fb413ec7e07b78af927550dd15ffe6 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:17:45 +0800 Subject: [PATCH 25/37] add todo --- TODO.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.md b/TODO.md index e39df4dd241..51d1a74ff38 100644 --- a/TODO.md +++ b/TODO.md @@ -20,6 +20,8 @@ - shfmt, shellcheck, bash LSP - Add preview capability for markdown files - Add json formatter + - leader f formating does not use current line length setting + - mypy does not check for function return type hint - Miscellaneous issues: From 9f96ad4388ca91d5ca14a8b52f0e084b8447f836 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sat, 31 Aug 2024 22:44:53 +0800 Subject: [PATCH 26/37] update private changes --- private_changes.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/private_changes.md b/private_changes.md index e05945eddbc..34a7a7c92d0 100644 --- a/private_changes.md +++ b/private_changes.md @@ -1,13 +1,28 @@ # Private changes + +- Keymaps + + - Use traditional completion keymaps + - LSP - - pyright + + - pylsp with all optional function turned on + - Did not turn on 3rd party plugins + - Auto install pylsp plugins at VimEnter + - Auto clean up lsp servers at VimEnter - Conform + - Add 'Format' command for manual formater trigger - Add 'FormatEnable' and 'FormatDisable' toggling format on write - Default disable format on write - Add ruff_fix/ruff_format/ruff_organize_imports as python formater - Add sqlfluff as SQL formater + - Add markdown-toc, markdownlint-cli2 and prettier as markdown formater + +- Telescope + + - Change telescope UI into vertical mode - Miscellaneous changes - JetbrainsMonoNL Nerd Font Mono From 144919cb4e96d76fad8c1037840510a69e64b0ec Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:12:16 +0800 Subject: [PATCH 27/37] treesitter parser and modules --- lua/kickstart/plugins/treesitter.lua | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index b026245adf3..d155f407d9f 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -5,7 +5,31 @@ return { main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'bash', + 'csv', + 'git_config', + 'git_rebase', + 'gitattributes', + 'gitcommit', + 'gitignore', + 'python', + 'rst', + 'sql', + 'tmux', + 'toml', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -16,6 +40,15 @@ return { additional_vim_regex_highlighting = { 'ruby' }, }, indent = { enable = true, disable = { 'ruby' } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = 'gnn', -- set to `false` to disable one of the mappings + node_incremental = 'grn', + scope_incremental = 'grc', + node_decremental = 'grm', + }, + }, }, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: From 66d639f1345d8140b1fc9b9d02a8f21550047379 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 11:34:37 +0800 Subject: [PATCH 28/37] Add treesitter-context --- lua/custom/plugins/init.lua | 17 +++++++++++++++++ lua/kickstart/plugins/treesitter.lua | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index f3e15034aef..fb5d4915e07 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -40,4 +40,21 @@ return { }, }, }, + { + 'nvim-treesitter/nvim-treesitter-context', + opts = { + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to show for a single context + trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + -- Separator between context and content. Should be a single character string, like '-'. + -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + separator = nil, + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + }, + }, } diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index d155f407d9f..86f01550f92 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -39,7 +39,6 @@ return { -- the list of additional_vim_regex_highlighting and disabled languages for indent. additional_vim_regex_highlighting = { 'ruby' }, }, - indent = { enable = true, disable = { 'ruby' } }, incremental_selection = { enable = true, keymaps = { @@ -49,6 +48,7 @@ return { node_decremental = 'grm', }, }, + indent = { enable = true, disable = { 'ruby' } }, }, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: From f0a3bd3ddd001133ac8ea6fa82493cf1522c0e89 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:10:40 +0800 Subject: [PATCH 29/37] add textobjects --- lua/custom/plugins/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index fb5d4915e07..dd1df94c99a 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -57,4 +57,7 @@ return { on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching }, }, + { + 'nvim-treesitter/nvim-treesitter-textobjects', -- TODO: set up keymaps + }, } From f27b43d97bbf616b106dd72c175d5850954e08d2 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:18:41 +0800 Subject: [PATCH 30/37] update docs and lock --- TODO.md | 3 +-- lazy-lock.json | 27 ++++++++++++++------------- private_changes.md | 6 ++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/TODO.md b/TODO.md index 7b324140dca..f46b54160cf 100644 --- a/TODO.md +++ b/TODO.md @@ -27,10 +27,9 @@ - Add highlight support for line diff for git commit and merge requests - Allow highlighting and moving the line (like hightlight with 'shift'+'ctrl'+up/down arrow key) - - Figure out a better way for autocomplete navigation and selection - Fix TODO highlight in docstring - - Add Mason ensure uninstalled (for pyright) - Nice to have - SQL LSP through local dll files - Go through LazyVim language setup for python/SQL/md + - Set up treesitter-textobjects keymaps (currently no example on lazy.vim) diff --git a/lazy-lock.json b/lazy-lock.json index 8a2c0941103..0ba52a12d6f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,30 +1,31 @@ { - "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, + "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "667102f26106709cddd2dff1f699610df5b94d7f" }, + "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, - "gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" }, - "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" }, + "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "3ed90180e70a6a50cd37ce7ecc3693bcdaa7b290" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "49e2699dc0d585b445eda24ed4bb45952ac20508" }, + "mini.nvim": { "branch": "main", "commit": "73f2e7a596bbb4e6ae6728d3a4426221ffc9512d" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-lint": { "branch": "master", "commit": "debabca63c0905b59ce596a55a8e33eafdf66342" }, - "nvim-lspconfig": { "branch": "master", "commit": "037ea0901ce9a28cfcaa36302618f06d2e164fbf" }, - "nvim-treesitter": { "branch": "master", "commit": "bfb50de9cb0673a3bff620d881f690fb7e0d1328" }, + "nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" }, + "nvim-treesitter": { "branch": "master", "commit": "64cc1ef764a0b137a642d05cacdfe1126124fb35" }, + "nvim-treesitter-context": { "branch": "master", "commit": "0ec9a8e00cedfb52e3c2259b55f46a7c18fc2429" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "3a3c6244553f13fdd92d312c82722b57ce6c4bec" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, - "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, - "tokyonight.nvim": { "branch": "main", "commit": "b0e7c7382a7e8f6456f2a95655983993ffda745e" }, + "todo-comments.nvim": { "branch": "main", "commit": "319c01b99b7a8c9ac2066bf0efd4d6ec68fef444" }, + "tokyonight.nvim": { "branch": "main", "commit": "4b386e66a9599057587c30538d5e6192e3d1c181" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" } + "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" } } diff --git a/private_changes.md b/private_changes.md index 34a7a7c92d0..d2e64e29e4b 100644 --- a/private_changes.md +++ b/private_changes.md @@ -11,6 +11,12 @@ - Auto install pylsp plugins at VimEnter - Auto clean up lsp servers at VimEnter +- Treesitter + - Ensure languages are installed (e.g. python) + - Enable incremental selection + - Enable treesitter-context + - Enable treesitter-textobjects (pending keymaps) + - Conform - Add 'Format' command for manual formater trigger From 67629963d6c8246090c910158246f78aa0ea5d26 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:37:07 +0800 Subject: [PATCH 31/37] add prettier and jq as json formater --- TODO.md | 1 - lua/kickstart/plugins/conform.lua | 1 + lua/kickstart/plugins/lspconfig.lua | 1 + private_changes.md | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index f46b54160cf..f0bd59967bd 100644 --- a/TODO.md +++ b/TODO.md @@ -16,7 +16,6 @@ - Set up LSP and formatter for bash script - shfmt, shellcheck, bash LSP - Add preview capability for markdown files - - Add json formatter - leader f formating does not use current line length setting - Auto detect vertical/horizontal monitor for telescope layout diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index 309063a37b6..e66712700a8 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -83,6 +83,7 @@ return { python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' }, sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, + json = { 'prettier', 'jq' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 314c8378a13..86f10f3377c 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -251,6 +251,7 @@ return { 'prettier', 'markdownlint-cli2', 'markdown-toc', + 'jq', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/private_changes.md b/private_changes.md index d2e64e29e4b..2ba01ec7eb4 100644 --- a/private_changes.md +++ b/private_changes.md @@ -25,6 +25,7 @@ - Add ruff_fix/ruff_format/ruff_organize_imports as python formater - Add sqlfluff as SQL formater - Add markdown-toc, markdownlint-cli2 and prettier as markdown formater + - Add prettier and jq as json formater - Telescope From 34a7641f2d0aae6a672c76ba048a17fcc42213a4 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:42:30 +0800 Subject: [PATCH 32/37] hotfix leader f key does not follow cli line length setting --- lua/kickstart/plugins/conform.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index e66712700a8..af1b7b6902a 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -42,6 +42,7 @@ return { { 'f', function() + require('conform').formatters.ruff_format = { append_args = { '--line-length', '120' } } require('conform').format { async = true, lsp_format = 'fallback' } end, mode = '', From e3cbc1a2081cc91bf6ad9af26fb4677db6b98b73 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:49:08 +0800 Subject: [PATCH 33/37] hotfix pylsp install script --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index c3024471387..9e8b8d2d1e7 100644 --- a/init.lua +++ b/init.lua @@ -108,8 +108,9 @@ require 'lazy-plugins' -- Run some neovim commands after setup vim.api.nvim_create_autocmd('VimEnter', { callback = function() + -- in case pylsp is not working as expected, try reinstalling through Mason vim.cmd.PylspInstall { 'pyls-flake8' } - vim.cmd.PylspInstall { 'pyls-mypy' } + vim.cmd.PylspInstall { 'pylsp-mypy' } vim.cmd.PylspInstall { 'pylsp-rope' } vim.cmd 'MasonToolsClean' end, From 4762e1b617a2320037ec890387d3806aacee1412 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:20:52 +0800 Subject: [PATCH 34/37] hotfix for auto lsp setup, fall back to manual setup --- TODO.md | 2 ++ init.lua | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index f0bd59967bd..195778b10d5 100644 --- a/TODO.md +++ b/TODO.md @@ -5,6 +5,7 @@ - No check for classmethod vs abstractmethod sequence - Warn if a class method is static - Use LSP to rename/delete files + - Auto setup for pylsp (e.g. PyslpInstall) - Minor issues: @@ -18,6 +19,7 @@ - Add preview capability for markdown files - leader f formating does not use current line length setting - Auto detect vertical/horizontal monitor for telescope layout + - Auto clean up unlisted lsp servers - Miscellaneous issues: diff --git a/init.lua b/init.lua index 9e8b8d2d1e7..e2a83d444b4 100644 --- a/init.lua +++ b/init.lua @@ -109,10 +109,10 @@ require 'lazy-plugins' vim.api.nvim_create_autocmd('VimEnter', { callback = function() -- in case pylsp is not working as expected, try reinstalling through Mason - vim.cmd.PylspInstall { 'pyls-flake8' } - vim.cmd.PylspInstall { 'pylsp-mypy' } - vim.cmd.PylspInstall { 'pylsp-rope' } - vim.cmd 'MasonToolsClean' + -- vim.cmd.PylspInstall { 'pyls-flake8' } + -- vim.cmd.PylspInstall { 'pylsp-mypy' } + -- vim.cmd.PylspInstall { 'pylsp-rope' } + -- vim.cmd 'MasonToolsClean' end, }) From b96a45445e38c44bb3cfb1d0793820dbe99914ff Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:54:21 +0800 Subject: [PATCH 35/37] toggle spell check at start --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index e2a83d444b4..7ee16c4747d 100644 --- a/init.lua +++ b/init.lua @@ -113,6 +113,7 @@ vim.api.nvim_create_autocmd('VimEnter', { -- vim.cmd.PylspInstall { 'pylsp-mypy' } -- vim.cmd.PylspInstall { 'pylsp-rope' } -- vim.cmd 'MasonToolsClean' + vim.cmd.setlocal { 'spell', 'spelllang=en_us' } end, }) From 214dd7e7a40e88ffc8540209b7e1932c9522c5b8 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:52:08 +0800 Subject: [PATCH 36/37] remove auto import and dupe called plugins to increase speed --- lua/kickstart/plugins/lspconfig.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 86f10f3377c..18fb732ac44 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -188,11 +188,18 @@ return { plugins = { flake8 = { enabled = true, - maxLineLength = 120, -- seems flake8 takes over pycodestyle + maxLineLength = 120, }, pycodestyle = { + enabled = false, -- Included in flake8 maxLineLength = 120, }, + mccabe = { + enabled = false, -- Included in flake8 + }, + pyflakes = { + enabled = false, -- Included in flake8 + }, pydocstyle = { enabled = true, convention = 'google', @@ -205,7 +212,7 @@ return { }, }, rope_autoimport = { - enabled = true, + enabled = false, }, rope_completion = { enabled = true, From 8cb6d2309b6f7f512c03b553f744498d4930c6a8 Mon Sep 17 00:00:00 2001 From: Safety_Mary <72537260+SafetyMary@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:43:23 +0800 Subject: [PATCH 37/37] add bash lsp and formatter --- lua/kickstart/plugins/conform.lua | 1 + lua/kickstart/plugins/lspconfig.lua | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index af1b7b6902a..67736a0b005 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -85,6 +85,7 @@ return { sql = { 'sqlfluff' }, markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' }, json = { 'prettier', 'jq' }, + sh = { 'bashls', 'shfmt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 18fb732ac44..7b278ba5863 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -259,6 +259,9 @@ return { 'markdownlint-cli2', 'markdown-toc', 'jq', + 'shellcheck', + 'shfmt', + 'bashls', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed }