diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 1ed593c..31955f1 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -3,6 +3,7 @@ "LazyVim": { "branch": "main", "commit": "fe72424e77cb9c953084bbcaaa0eb7fe8056dc70" }, "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, "SchemaStore.nvim": { "branch": "main", "commit": "adaca44ad56bd74ae0e4e500320a7dd6f216650a" }, + "barbar.nvim": { "branch": "master", "commit": "dd852401ee902745b67fc09a83d113b3fe82a96f" }, "bufferline.nvim": { "branch": "main", "commit": "b15c6daf5a64426c69732b31a951f4e438cb6590" }, "catppuccin": { "branch": "main", "commit": "9703f227bfab20d04bcee62d2f08f1795723b4ae" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -10,7 +11,7 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "b8624e46d83c8b59e5d4a773bdcae6ffc3b9639a" }, + "conform.nvim": { "branch": "master", "commit": "bfae1d80d88607921e2ba5d75fd41bf88f0cd6c9" }, "dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, @@ -20,6 +21,7 @@ "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "lsp_signature.nvim": { "branch": "master", "commit": "fed2c8389c148ff1dfdcdca63c2b48d08a50dea0" }, + "lspsaga.nvim": { "branch": "main", "commit": "b1b140aa20a0cf353cd3e282870429b48b30a169" }, "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "60f6805b12a12e8a912aeb2f975dec1794a8994e" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, @@ -31,19 +33,19 @@ "mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "f3941c57ec85d7bdb44fa53fd858fd80f159018f" }, "neoconf.nvim": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" }, - "neodev.nvim": { "branch": "main", "commit": "fdf6b3c58caf3ed1bfe40822d5dac340fc18c33b" }, + "neodev.nvim": { "branch": "main", "commit": "b0ccf605c952eb0d1efe3692d5b241c52ceee187" }, "neotest": { "branch": "master", "commit": "f6048f32be831907fb15018af2688ff6633704fc" }, "neotest-go": { "branch": "main", "commit": "ba5d536304ed6971f00d16b48ec26997622ffb43" }, "neotest-plenary": { "branch": "master", "commit": "dcaf5ed67a9e28a246e9783319e5aa6c9ea1c584" }, "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, "nui.nvim": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, - "nvim-lint": { "branch": "master", "commit": "99f93757276ea55c35bbe74ad2a3d25fc504643b" }, - "nvim-lspconfig": { "branch": "master", "commit": "aa199c5bbdbb7fd28b56212a89206f13db02799e" }, + "nvim-lint": { "branch": "master", "commit": "6f6d866362c74ec2eb036c32b56fac50b02af669" }, + "nvim-lspconfig": { "branch": "master", "commit": "6b9f4bbe0aa1f351fd4845dc5fd4f3450b010f88" }, "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, "nvim-spectre": { "branch": "master", "commit": "3712ff0cdf4f9f877d9ca708d835a877d9a0abaf" }, "nvim-tree.lua": { "branch": "master", "commit": "030defdb6522f5f716d8201d20ca1a2baa57ca66" }, - "nvim-treesitter": { "branch": "master", "commit": "d1484a1507b36ca6af7f7925c627846010faeabe" }, + "nvim-treesitter": { "branch": "master", "commit": "1398b1ba4619cef240abd496b500b95819c8c496" }, "nvim-treesitter-context": { "branch": "master", "commit": "98bdd713ffab5543f60ff1beaeba5c4918915e1b" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index 3127f19..79d03af 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -24,8 +24,6 @@ local mappings = { }, b = { name = "+Buffer", - n = { "BufferNext", "next buffer" }, - p = { "BufferPrevious", "previous buffer" }, q = { "q", "quit" }, s = { "w", "save" }, r = { "e!", "reload" }, @@ -155,7 +153,7 @@ local mappings = { f = { "Fzflua files", "Find File" }, m = { "Telescope marks", "Marks" }, M = { "Telescope man_pages", "Man Pages" }, - r = { "FzfLua oldfiles", "Open Recent File" }, + -- r = { "Telescope oldfiles ", "Open Recent File" }, R = { "Telescope registers", "Registers" }, t = { "FzfLua live_grep", "Text" }, ["#"] = { "FzfLua grep_cword", "Search word under cursor" }, @@ -239,8 +237,8 @@ keymap.set('i', 'kj', '', { noremap = true, silent = true }) keymap.set('i', 'jj', '', { noremap = true, silent = true }) -- Tab switch buffer -keymap.set('n', '', ':bnext', { noremap = true, silent = true }) -keymap.set('n', '', ':bprevious', { noremap = true, silent = true }) +keymap.set('n', '', ':BufferNext', { noremap = true, silent = true }) +keymap.set('n', '', ':BufferPrevious', { noremap = true, silent = true }) -- Move selected line / block of text in visual mode keymap.set('x', 'K', ':move \'<-2gv-gv', { noremap = true, silent = true }) diff --git a/nvim/lua/plugins/formatting.lua b/nvim/lua/plugins/formatting.lua index 1cac78c..7db415d 100644 --- a/nvim/lua/plugins/formatting.lua +++ b/nvim/lua/plugins/formatting.lua @@ -1,5 +1,6 @@ return { { "stevearc/conform.nvim", + } } \ No newline at end of file diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 67740be..538c22a 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -40,12 +40,12 @@ return { cssls = {}, tailwindcss = { root_dir = function(...) - return require("lspconfig.util").root_pattern(".git")(...) + return require("lspconfig.util").root_pattern('tailwind.config.js', 'tailwind.config.cjs', 'tailwind.config.mjs', 'tailwind.config.ts', 'postcss.config.js', 'postcss.config.cjs', 'postcss.config.mjs', 'postcss.config.ts', 'package.json', 'node_modules', '.git')(...) end, }, tsserver = { root_dir = function(...) - return require("lspconfig.util").root_pattern(".git")(...) + return require("lspconfig.util").root_pattern("tsconfig.json", "package.json", "jsconfig.json", ".git")(...) end, single_file_support = false, settings = { diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..c09dd5c --- /dev/null +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,85 @@ +local function keymapping(cmp) + return { + -- 上一个 + [''] = cmp.mapping.select_prev_item(), + -- 下一个 + [''] = cmp.mapping.select_next_item(), + -- 出现补全 + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + -- 取消 + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- 确认 + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.confirm({ + select = true, + behavior = cmp.ConfirmBehavior.Replace + }), + -- [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + } +end + +local function opts_func (_, opts) + local cmp = require("cmp") + -- Use buffer source for `/`. + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' }, + { name = "emoji" }, + } + }) + + -- Use cmdline & path source for ':'. + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + return { + mapping = keymapping(cmp), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + -- For vsnip users. + { name = 'vsnip' }, + -- For luasnip users. + -- { name = 'luasnip' }, + --For ultisnips users. + -- { name = 'ultisnips' }, + -- -- For snippy users. + -- { name = 'snippy' }, + { name = 'emoji'} + }, { { name = 'buffer' }, + { name = 'path' } + }), + snippet = { + expand = function(args) + -- For `vsnip` users. + vim.fn["vsnip#anonymous"](args.body) + + -- For `luasnip` users. + -- require('luasnip').lsp_expand(args.body) + + -- For `ultisnips` users. + -- vim.fn["UltiSnips#Anon"](args.body) + + -- For `snippy` users. + -- require'snippy'.expand_snippet(args.body) + end, + }, + } +end + +return { + { + "nvim-cmp", + dependencies = { "hrsh7th/cmp-emoji" }, + opts = opts_func, + }, +} \ No newline at end of file diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/symbols-outline.lua similarity index 57% rename from nvim/lua/plugins/coding.lua rename to nvim/lua/plugins/symbols-outline.lua index 1416f68..851128b 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/symbols-outline.lua @@ -7,11 +7,4 @@ return { position = "right", }, }, - { - "nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, - opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) - end, - }, } \ No newline at end of file diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..e7a7ee3 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,187 @@ +return { + { + "telescope.nvim", + dependencies = { + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + "nvim-telescope/telescope-file-browser.nvim", + }, + keys = { + { + "fP", + function() + require("telescope.builtin").find_files({ + cwd = require("lazy.core.config").options.root, + }) + end, + desc = "Find Plugin File", + }, + { + "sr", + function() + require("telescope.builtin").oldfiles({ + cwd = vim.loop.cwd() + }) + end, + desc = "Find Recent File", + }, + { + ";f", + function() + local builtin = require("telescope.builtin") + builtin.find_files({ + no_ignore = false, + hidden = true, + }) + end, + desc = "Lists files in your current working directory, respects .gitignore", + }, + { + ";r", + function() + local builtin = require("telescope.builtin") + builtin.live_grep({ + additional_args = { "--hidden" }, + }) + end, + desc = "Search for a string in your current working directory and get results live as you type, respects .gitignore", + }, + { + "\\\\", + function() + local builtin = require("telescope.builtin") + builtin.buffers() + end, + desc = "Lists open buffers", + }, + { + ";t", + function() + local builtin = require("telescope.builtin") + builtin.help_tags() + end, + desc = "Lists available help tags and opens a new window with the relevant help info on ", + }, + { + ";;", + function() + local builtin = require("telescope.builtin") + builtin.resume() + end, + desc = "Resume the previous telescope picker", + }, + { + ";e", + function() + local builtin = require("telescope.builtin") + builtin.diagnostics() + end, + desc = "Lists Diagnostics for all open buffers or a specific buffer", + }, + { + ";s", + function() + local builtin = require("telescope.builtin") + builtin.treesitter() + end, + desc = "Lists Function names, variables, from Treesitter", + }, + { + "sf", + function() + local telescope = require("telescope") + + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") + end + + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = false, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 }, + }) + end, + desc = "Open File Browser with the path of the current buffer", + }, + }, + config = function(_, opts) + local telescope = require("telescope") + local actions = require("telescope.actions") + local fb_actions = require("telescope").extensions.file_browser.actions + local trouble = require("trouble.providers.telescope") + + opts.defaults = vim.tbl_deep_extend("force", opts.defaults, { + wrap_results = true, + layout_strategy = "horizontal", + layout_config = { prompt_position = "top" }, + sorting_strategy = "ascending", + winblend = 0, + mappings = { + i = { + [""] = actions.close, + [""] = actions.close, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = trouble.open_with_trouble, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = trouble.open_with_trouble, + [""] = actions.smart_send_to_qflist + actions.open_qflist + }, + }, + }) + opts.pickers = { + diagnostics = { + theme = "ivy", + initial_mode = "normal", + layout_config = { + preview_cutoff = 9999, + }, + }, + } + opts.extensions = { + file_browser = { + theme = "dropdown", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + -- your custom insert mode mappings + ["n"] = { + -- your custom normal mode mappings + ["N"] = fb_actions.create, + ["h"] = fb_actions.goto_parent_dir, + ["/"] = function() + vim.cmd("startinsert") + end, + [""] = function(prompt_bufnr) + for i = 1, 10 do + actions.move_selection_previous(prompt_bufnr) + end + end, + [""] = function(prompt_bufnr) + for i = 1, 10 do + actions.move_selection_next(prompt_bufnr) + end + end, + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + }, + }, + }, + } + telescope.setup(opts) + require("telescope").load_extension("fzf") + require("telescope").load_extension("file_browser") + end, + }, +} \ No newline at end of file diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index 6b4b860..4ac83e1 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -1,4 +1,19 @@ return { + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status + 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons + }, + init = function() vim.g.barbar_auto_setup = false end, + opts = { + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + -- animation = true, + -- insert_at_start = true, + -- …etc. + }, + version = '^1.0.0', -- optional: only update when a new 1.x version is released + }, { "nvimdev/dashboard-nvim", event = "VimEnter",