diff --git a/init.lua b/init.lua index 424e48d..3ba2447 100644 --- a/init.lua +++ b/init.lua @@ -25,3 +25,6 @@ end require "lazy_setup" require "polish" + +vim.g.copilot_no_tab_map = true + diff --git a/lazy-lock.json b/lazy-lock.json index ea7dab7..f2c2a5e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,9 +6,12 @@ "astrolsp": { "branch": "main", "commit": "414775e4b49a46bd7105cc5498ea7bb312359bf2" }, "astrotheme": { "branch": "main", "commit": "0a3fb361f1e3d6a0cbb42e93f3d01fb5203b6752" }, "astroui": { "branch": "main", "commit": "4943abbd42674b43249313afe83b91065a40e4be" }, + "auto-save.nvim": { "branch": "main", "commit": "37c82fd548e3f5ffc2d9d020a65dac1044584f44" }, "bamboo.nvim": { "branch": "master", "commit": "56c924d0cbd3a37f9d0ea1235a189a3cccde1f44" }, "better-escape.nvim": { "branch": "master", "commit": "199dcc2643dec5d8dbdab4ec672cf405224dcb3b" }, "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, + "copilot.vim": { "branch": "release", "commit": "f3d66c148aa60ad04c0a21d3e0a776459de09eb2" }, + "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "7010000889bfb6c26065e0b0f7f1e6aa9163edd9" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, @@ -22,6 +25,8 @@ "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "197f6352c276bbc2d25541dfce00ec50d1a4e88f" }, "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, + "mini.move": { "branch": "main", "commit": "819e90c3e113a3c826c3003ec07073f1e0677ea0" }, + "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, "neo-tree.nvim": { "branch": "main", "commit": "cea666ef965884414b1b71f6b39a537f9238bdb2" }, "neoconf.nvim": { "branch": "main", "commit": "5aeca07ecb2f506d32e81eb82b0ed384ac2a53c5" }, "none-ls-extras.nvim": { "branch": "main", "commit": "924fe88a9983c7d90dbb31fc4e3129a583ea0a90" }, @@ -33,10 +38,13 @@ "nvim-highlight-colors": { "branch": "main", "commit": "1ce0a09bfc28c7274e649d20927cea51e440b65c" }, "nvim-lsp-endhints": { "branch": "main", "commit": "f977426055fc6b5c6449b416e08e2462f59b9317" }, "nvim-lspconfig": { "branch": "master", "commit": "fa2662510d30b06168b6e2e6915518decde6bbac" }, + "nvim-spider": { "branch": "main", "commit": "53ba761cd40c1d683e8477d138ff03cd7e6e384a" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "dca8726fea2c14e1ce6adbaa76a04816fbfaff61" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" }, + "nvim_context_vt": { "branch": "master", "commit": "b69f642f7848fec8c056a7e2c9452e3dec84c2b5" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, @@ -46,5 +54,6 @@ "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "e65731d50c548c020f3961bb42071671f0fa923c" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "which-key.nvim": { "branch": "main", "commit": "fcbf4eea17cb299c02557d576f0d568878e354a4" } } diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index e69de29..f26b5a5 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -0,0 +1,41 @@ +-- Some commands that I want to execute in specific timing +vim.api.nvim_create_augroup("disable_comment_newline", { clear = true }) +vim.api.nvim_create_augroup("auto_wrap", { clear = true }) +vim.api.nvim_create_augroup("disable_suspend_with_c_z", { clear = true }) +vim.api.nvim_create_augroup("clear_last_search", { clear = true }) + +vim.keymap.set("v", "K", "", { silent = true }) + +-- NOTE: Set colors for hightlights for similar words +-- vim.api.nvim_set_hl(0, "LspReferenceRead", { fg = "#FF0000" }) +-- vim.api.nvim_set_hl(0, "LspReferenceWrite", { fg = "#FF0000" }) +-- vim.api.nvim_set_hl(0, "LspReferenceText", { fg = "#FF0000" }) + +vim.api.nvim_create_autocmd("BufEnter", { + desc = "Disable auto insert comment newline", + group = "disable_comment_newline", + command = "set formatoptions-=cro", +}) + +vim.api.nvim_create_autocmd("FileType", { + desc = "Enable wrap and spell for text like documents", + group = "auto_wrap", + pattern = { "gitcommit", "markdown", "text", "plaintext" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.api.nvim_create_autocmd("BufEnter", { + desc = "Remap to nothing so that it doesn't suspend terminal", + group = "disable_suspend_with_c_z", + command = "nnoremap ", +}) + +vim.api.nvim_create_autocmd("BufWinEnter", { + desc = "Clear last search pattern", + group = "clear_last_search", + pattern = "*", + command = "let @/ = ''", +}) diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index 5eda3fa..02e5fdc 100644 --- a/lua/plugins/astrolsp.lua +++ b/lua/plugins/astrolsp.lua @@ -175,7 +175,6 @@ return { client.server_capabilities.workspaceSymbolProvider = false client.server_capabilities.monikerProvider = false client.server_capabilities.semanticTokensProvider = false - -- Tắt thêm các capabilities khác có thể có client.server_capabilities.referencesProvider = false client.server_capabilities.implementationProvider = false @@ -187,7 +186,6 @@ return { workspaceFolders = { supported = false }, fileOperations = { supported = false } } - -- Giữ lại diagnostics và inlay hints -- client.server_capabilities.diagnosticProvider = true (mặc định) -- client.server_capabilities.inlayHintProvider = true (mặc định) diff --git a/lua/plugins/auto-save.lua b/lua/plugins/auto-save.lua new file mode 100644 index 0000000..9a53c55 --- /dev/null +++ b/lua/plugins/auto-save.lua @@ -0,0 +1,44 @@ + -- Auto-save functionality +return { + "okuuva/auto-save.nvim", + event = { "User AstroFile", "InsertEnter" }, + dependencies = { + "AstroNvim/astrocore", + opts = { + autocmds = { + autoformat_toggle = { + { + event = "User", + desc = "Disable autoformat before saving", + pattern = "AutoSaveWritePre", + callback = function() + vim.g.OLD_AUTOFORMAT = vim.g.autoformat + vim.g.autoformat = false + local old_autoformat_buffers = {} + for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + if vim.b[bufnr].autoformat then + table.insert(old_autoformat_buffers, bufnr) + vim.b[bufnr].autoformat = false + end + end + vim.g.OLD_AUTOFORMAT_BUFFERS = old_autoformat_buffers + end, + }, + { + event = "User", + desc = "Re-enable autoformat after saving", + pattern = "AutoSaveWritePost", + callback = function() + vim.g.autoformat = vim.g.OLD_AUTOFORMAT + for _, bufnr in ipairs(vim.g.OLD_AUTOFORMAT_BUFFERS or {}) do + vim.b[bufnr].autoformat = true + end + end, + }, + }, + }, + }, + }, + opts = {}, + } + diff --git a/lua/plugins/cmps.lua b/lua/plugins/cmps.lua new file mode 100644 index 0000000..49764bd --- /dev/null +++ b/lua/plugins/cmps.lua @@ -0,0 +1,52 @@ +return { + { + "github/copilot.vim", + event = "BufRead", + config = function() + vim.api.nvim_set_keymap("i", "", 'copilot#Accept("\\")', { expr = true, silent = true }) + end, + }, + + { + "Saghen/blink.cmp", + opts = { + completion = { + list = { selection = { preselect = true, auto_insert = true } }, + ghost_text = { + enabled = false, + }, + menu = { + auto_show = function(ctx) + return ctx.mode ~= "cmdline" + end, + draw = { + columns = { + { "kind_icon", "label", gap = 1 }, + { "kind" }, + }, + components = { + kind = { + highlight = function(ctx) + local _, hl, _ = require("mini.icons").get("lsp", ctx.kind) + return hl + end, + }, + + }, + }, + }, + accept = { + auto_brackets = { enabled = true }, + }, + documentation = { + auto_show = true, + auto_show_delay_ms = 0, + window = { + border = "rounded", + winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", + }, + }, + }, + } +} +} diff --git a/lua/plugins/configs/lsp/config/ruff.lua b/lua/plugins/configs/lsp/config/ruff.lua index 4998bbd..b21e2ce 100644 --- a/lua/plugins/configs/lsp/config/ruff.lua +++ b/lua/plugins/configs/lsp/config/ruff.lua @@ -1,26 +1,56 @@ return { - before_init = function(_, c) - if not c.settings then - c.settings = {} - end - if not c.settings.python then - c.settings.python = {} - end - c.settings.python.pythonPath = vim.fn.exepath("python") - end, - settings = { - pyright = { - disableLanguageServices = false, - disableOrganizeImports = true, - analysis = { - -- diagnosticMode = "openFilesOnly", - typeCheckingMode = "standard", - autoSearchPath = true, - -- diagnosticSeverityOverrides = false, - logLevel = "Trace", - }, - }, - -- python = { - -- }, - }, + init_options = { + settings = { + lint = { + unfixable = { "F401" }, + select = { + "ALL", + }, + ignore = { + "ANN", + "COM", + "C90", + "DJ", + "EXE", + "T10", + "TID", + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D200", + "D205", + "D212", + "D400", + "D401", + "D415", + "E402", + "E501", + "ERA001", + "TRY003", + "TD002", + "TD003", + "T201", + "FIX002", + "N803", + "PD901", + -- "F401", + "I001", + "RET504", + "PLR2004", + "W291", + "PLW2901", + "D213", + "D202", + "PLR0402", + "EM101", + "TRY301", + }, + }, + }, + }, } diff --git a/lua/plugins/contexts.lua b/lua/plugins/contexts.lua new file mode 100644 index 0000000..50fb781 --- /dev/null +++ b/lua/plugins/contexts.lua @@ -0,0 +1,49 @@ + -- Treesitter context +return { + { + "nvim-treesitter/nvim-treesitter-context", + event = "User AstroFile", + cmd = { "TSContext" }, + opts = { + on_attach = function() + vim.api.nvim_set_hl(0, "TreesitterContext", { underline = true, sp = "Red", bg = "#1e1e3f" }) + end, + max_lines = 2, + }, + dependencies = { + "AstroNvim/astrocore", + opts = { + mappings = { + n = { + ["uT"] = { + "TSContext toggle", + desc = "Toggle treesitter context", + }, + }, + }, + }, + }, + }, + + -- Virtual text context + { + "andersevenrud/nvim_context_vt", + event = "User AstroFile", + cmd = { "NvimContextVtToggle" }, + dependencies = { + "AstroNvim/astrocore", + opts = { + mappings = { + n = { + ["uv"] = { + function() + require("nvim_context_vt").toggle() + end, + desc = "Toggle virutal text context", + }, + }, + }, + }, + }, + } +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index b4a7bb2..ef17d47 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -20,6 +20,16 @@ return { -- install any other package "tree-sitter-cli", }, + ui = { + border = "single", + width = 0.8, + height = 0.9, + icons = { + package_installed = "  ", + package_pending = "  ", + package_uninstalled = "  ", + } + } }, }, } diff --git a/lua/plugins/motions.lua b/lua/plugins/motions.lua new file mode 100644 index 0000000..9852e3d --- /dev/null +++ b/lua/plugins/motions.lua @@ -0,0 +1,127 @@ +-- Motion, Navigation and Multiple Cursors +return { + -- Multi-cursors support + { + "brenton-leighton/multiple-cursors.nvim", + version = "*", + opts = {}, + keys = { + { "", "MultipleCursorsAddDown", mode = { "n", "i", "x" } }, + { "", "MultipleCursorsAddUp", mode = { "n", "i", "x" } }, + { "", "MultipleCursorsMouseAddDelete", mode = { "n", "i" } }, + { "a", "MultipleCursorsAddMatches", mode = { "n", "x" } }, + { "", "MultipleCursorsAddJumpNextMatch", mode = { "n", "x" } }, + }, + }, + -- Alternative multi-cursor plugin + { + "mg979/vim-visual-multi", + event = "BufRead", + }, + -- Better move by word + { + "chrisgrieser/nvim-spider", + opts = {}, + keys = { + { "w", "lua require('spider').motion('w')", mode = { "n", "o", "x" }, desc = "Spider-w" }, + { "e", "lua require('spider').motion('e')", mode = { "n", "o", "x" }, desc = "Spider-e" }, + { "b", "lua require('spider').motion('b')", mode = { "n", "o", "x" }, desc = "Spider-b" }, + { "ge", "lua require('spider').motion('ge')", mode = { "n", "o", "x" }, desc = "Spider-ge" }, + }, + }, + + -- Better character motion + { + "folke/flash.nvim", + event = "VeryLazy", + opts = {}, + keys = { + { "gj", function() require("flash").jump() end, mode = { "n", "x", "o" }, desc = "Flash" }, + { + "gJ", + function() require("flash").treesitter() end, + mode = { "n", "x", "o" }, + desc = "Flash Treesitter", + }, + { "r", function() require("flash").remote() end, mode = "o", desc = "Remote Flash" }, + { + "R", + function() require("flash").treesitter_search() end, + mode = { "x", "o" }, + desc = "Treesitter Search", + }, + }, + }, + + -- Move code block + { + "echasnovski/mini.move", + event = "BufRead", + config = function() + require("mini.move").setup { + mappings = { + left = "", + right = "", + down = "", + up = "", + line_left = "", + line_right = "", + line_down = "", + line_up = "", + }, + } + end, + }, + + { + "mrjones2014/smart-splits.nvim", + event = "VeryLazy", + opts = function(_, opts) + opts.ignored_filetypes = { "nofile", "quickfix", "qf", "prompt", "NvimTree" } + opts.ignored_buftypes = { "nofile" } + opts.log_level = "error" + end, + keys = { + { + "", + function() require("smart-splits").move_cursor_left() end, + mode = { "n" }, + desc = "Move to left split", + }, + { + "", + function() require("smart-splits").move_cursor_right() end, + mode = { "n", "t" }, + desc = "Move to right split", + }, + { + "", + function() require("smart-splits").move_cursor_up() end, + mode = { "n" }, + desc = "Move to above split", + }, + { + "", + function() require("smart-splits").move_cursor_down() end, + mode = { "n" }, + desc = "Move to below split", + }, + { + "", + function() require("smart-splits").resize_left() end, + mode = { "n" }, + desc = "Resize split left", + }, + { + "", + function() require("smart-splits").resize_right() end, + mode = { "n" }, + desc = "Resize split right", + }, + }, + }, + + -- Disabled motion plugins + { "Wansmer/treesj", enabled = false }, + +} diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua deleted file mode 100644 index 0e2587d..0000000 --- a/lua/plugins/themes.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - { - "ribru17/bamboo.nvim", - lazy = false, - priority = 1000, - config = function() - require("bamboo").setup { - integrations = { mini = true }, - terminal_colors = false - } - require("bamboo").load() - end, - }, -} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..8827d2f --- /dev/null +++ b/lua/plugins/ui.lua @@ -0,0 +1,43 @@ +return { + { + "ribru17/bamboo.nvim", + lazy = false, + priority = 1000, + config = function() + require("bamboo").setup { + integrations = { mini = true }, + terminal_colors = false + } + require("bamboo").load() + end, + }, + { + "rebelot/heirline.nvim", + opts = function(_, opts) + opts.statusline = require("plugins.configs.ui.heirline").statusline + opts.winbar = require("plugins.configs.ui.heirline").winbar + end, + }, + { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + preset = "helix", + layout = { + height = { min = 6 }, + }, + }, + keys = { + { + "?", + function() require("which-key").show { global = false } end, + desc = "Buffer Local Keymaps (which-key)", + }, + + }, + } +} + diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua index 24a4a0f..82d3c2b 100644 --- a/lua/plugins/user.lua +++ b/lua/plugins/user.lua @@ -29,34 +29,32 @@ return { keys = {}, }, }, - scope = { - char = "󰥓" - }, + indent = { priority = 1, enabled = true, -- enable indent guides - char = "l", - only_scope = false, -- only show indent guides of the scope + -- char = "l", + only_scope = true, -- only show indent guides of the scope only_current = false, -- only show indent guides in the current window hl = "SnacksIndent", ---@type string|string[] hl groups for indent guides - animate = { - enabled = vim.fn.has("nvim-0.10") == 1, - style = "out", - easing = "linear", - duration = { - step = 20, -- ms per step - total = 500, -- maximum duration - }, - }, - ---@class snacks.indent.Scope.Config: snacks.scope.Config - scope = { - enabled = true, -- enable highlighting the current scope - priority = 200, - char = "󰥓", - underline = false, -- underline the start of the scope - only_current = false, -- only show scope in the current window - hl = "SnacksIndentScope", ---@type string|string[] hl group for scopes - }, + + animate = { + enabled = vim.fn.has("nvim-0.10") == 1, + style = "out", + easing = "linear", + duration = { + step = 10, -- ms per step + total = 500, -- maximum duration + }, + }, + scope = { + enabled = true, -- enable highlighting the current scope + priority = 200, + char = "󰥓", + underline = false, -- underline the start of the scope + only_current = false, -- only show scope in the current window + hl = "SnacksIndentScope", ---@type string|string[] hl group for scopes + }, }, }, }, diff --git a/lua/polish.lua b/lua/polish.lua index 642719f..7b590d3 100644 --- a/lua/polish.lua +++ b/lua/polish.lua @@ -1,5 +1,6 @@ -if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE - -- This will run last in the setup process. -- This is just pure lua so anything that doesn't -- fit in the normal config locations above can go here + +require"core.autocmds" +