From b767beebd0571c775c58ec46b6bf88fd449fa046 Mon Sep 17 00:00:00 2001 From: doryan Date: Mon, 2 Sep 2024 23:36:54 +0400 Subject: [PATCH] feat: correct my lvim config --- lvim/config.lua | 9 +++++ lvim/lazy-lock.json | 6 +++ lvim/lua/configs/acmp.lua | 5 +++ lvim/lua/configs/autotag.lua | 8 ++++ lvim/lua/configs/colorizer.lua | 19 ++++++++++ lvim/lua/configs/dap.lua | 24 +++++++++--- lvim/lua/configs/luasnip.lua | 22 +++++++++++ lvim/lua/configs/nvimufo.lua | 19 ++++++++++ lvim/lua/configs/prettier.lua | 19 ++++++++++ lvim/lua/plugins/init.lua | 68 ++++++++++++++++++++++++++-------- 10 files changed, 178 insertions(+), 21 deletions(-) create mode 100644 lvim/lua/configs/acmp.lua create mode 100644 lvim/lua/configs/autotag.lua create mode 100644 lvim/lua/configs/colorizer.lua create mode 100644 lvim/lua/configs/luasnip.lua create mode 100644 lvim/lua/configs/nvimufo.lua create mode 100644 lvim/lua/configs/prettier.lua diff --git a/lvim/config.lua b/lvim/config.lua index 72be6a2..f4954d8 100644 --- a/lvim/config.lua +++ b/lvim/config.lua @@ -7,6 +7,8 @@ lvim.colorscheme = "melange" lvim.builtin.breadcrumbs.active = false +vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer", "rust-analyzer" }) + require "plugins.init" require "mappings" require "configs.noice" @@ -14,3 +16,10 @@ require "configs.nvimtree" require "configs.bufferline" require "configs.dropbar" require "configs.dap" +require "configs.acmp" +require "configs.colorizer" +require "configs.autotag" +require "configs.prettier" +require "configs.nvimufo" + +vim.lsp.inlay_hint.enable(true) diff --git a/lvim/lazy-lock.json b/lvim/lazy-lock.json index 31e9a48..783edad 100755 --- a/lvim/lazy-lock.json +++ b/lvim/lazy-lock.json @@ -7,6 +7,7 @@ "catppuccin": { "branch": "main", "commit": "ba5f4153a5dad99505baba936bd0373534400ac3" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, @@ -41,6 +42,7 @@ "nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" }, "nvim-dap": { "branch": "master", "commit": "13ce59d4852be2bb3cd4967947985cb0ceaff460" }, "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "484995d573c0f0563f6a66ebdd6c67b649489615" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, @@ -48,10 +50,13 @@ "nvim-treesitter": { "branch": "master", "commit": "d5a1c2b0c8ec5bb377a41c1c414b315d6b3e9432" }, "nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bdccb9c67a42a5e2d99384dc9bfa29b1451528f" }, + "nvim-ufo": { "branch": "main", "commit": "b23a46aa06f5f653d107efbc67fd2aa3877ac344" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, "onedarker.nvim": { "branch": "freeze", "commit": "b00dd2189f264c5aeb4cf04c59439655ecd573ec" }, "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, "rustaceanvim": { "branch": "master", "commit": "047f9c9d8cd2861745eb9de6c1570ee0875aa795" }, "schemastore.nvim": { "branch": "main", "commit": "8c46453bdf84ad91877effb95e0b6c7b51ea7dda" }, @@ -65,6 +70,7 @@ "vim": { "branch": "legacy", "commit": "99d4b7bf1a0a12f2d78f35a159384b1eb8aa9c15" }, "vim-illuminate": { "branch": "master", "commit": "e522e0dd742a83506db0a72e1ced68c9c130f185" }, "vim-react-snippets": { "branch": "main", "commit": "755e288bd0db1052be4195fcc82a25e28b609e0b" }, + "vim-rustfmt": { "branch": "master", "commit": "6bb517be12908926a4f5f516aa510c517c85260e" }, "vscode-js-debug": { "branch": "main", "commit": "ca1c6450490dab5d742eac16a08d593533a1a13d" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, "winbar.nvim": { "branch": "main", "commit": "13739fdb31be51a1000486189662596f07a59a31" } diff --git a/lvim/lua/configs/acmp.lua b/lvim/lua/configs/acmp.lua new file mode 100644 index 0000000..79e5a54 --- /dev/null +++ b/lvim/lua/configs/acmp.lua @@ -0,0 +1,5 @@ +require'cmp'.setup { + sources = { + { name = 'nvim_lsp' } + } +} diff --git a/lvim/lua/configs/autotag.lua b/lvim/lua/configs/autotag.lua new file mode 100644 index 0000000..92c7ea3 --- /dev/null +++ b/lvim/lua/configs/autotag.lua @@ -0,0 +1,8 @@ +require('nvim-ts-autotag').setup({ + opts = { + -- Defaults + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false -- Auto close on trailing ui', require 'dapui'.toggle) + diff --git a/lvim/lua/configs/luasnip.lua b/lvim/lua/configs/luasnip.lua new file mode 100644 index 0000000..18a6094 --- /dev/null +++ b/lvim/lua/configs/luasnip.lua @@ -0,0 +1,22 @@ +-- vscode format +require("luasnip.loaders.from_vscode").lazy_load { exclude = vim.g.vscode_snippets_exclude or {} } +require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } + +-- snipmate format +require("luasnip.loaders.from_snipmate").load() +require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } + +-- lua format +require("luasnip.loaders.from_lua").load() +require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } + +vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, +}) diff --git a/lvim/lua/configs/nvimufo.lua b/lvim/lua/configs/nvimufo.lua new file mode 100644 index 0000000..6a61298 --- /dev/null +++ b/lvim/lua/configs/nvimufo.lua @@ -0,0 +1,19 @@ +vim.o.foldcolumn = '1' -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true +vim.o.fillchars = [[eob: ,fold: ,foldopen:ó°…€,foldsep:â•Ž,foldclose:ó°…‚]] + +-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself +vim.keymap.set('n', 'zR', require('ufo').openAllFolds) +vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) + +-- Option 3: treesitter as a main provider instead +-- (Note: the `nvim-treesitter` plugin is *not* needed.) +-- ufo uses the same query files for folding (queries//folds.scm) +-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` +require('ufo').setup({ + provider_selector = function(bufnr, filetype, buftype) + return {'treesitter', 'indent'} + end +}) diff --git a/lvim/lua/configs/prettier.lua b/lvim/lua/configs/prettier.lua new file mode 100644 index 0000000..74aacdb --- /dev/null +++ b/lvim/lua/configs/prettier.lua @@ -0,0 +1,19 @@ +local prettier = require("prettier") + +prettier.setup({ + bin = 'prettier', -- or `'prettierd'` (v0.23.3+) + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + }, +}) diff --git a/lvim/lua/plugins/init.lua b/lvim/lua/plugins/init.lua index 7b523b2..a781881 100644 --- a/lvim/lua/plugins/init.lua +++ b/lvim/lua/plugins/init.lua @@ -10,9 +10,27 @@ lvim.plugins = { } } }, + { + 'kevinhwang91/nvim-ufo', + }, + { + 'kevinhwang91/promise-async', + }, + { + 'rust-lang/rust.vim', + }, + { + 'MunifTanjim/prettier.nvim' + }, + { + 'alx741/vim-rustfmt', + }, { "savq/melange-nvim" }, + { + 'theHamsta/nvim-dap-virtual-text', + }, { "HoNamDuong/hybrid.nvim", lazy = false, @@ -38,9 +56,9 @@ lvim.plugins = { "vague2k/huez.nvim", }, { - 'Bekaboo/dropbar.nvim', + "Bekaboo/dropbar.nvim", dependencies = { - 'nvim-telescope/telescope-fzf-native.nvim' + "nvim-telescope/telescope-fzf-native.nvim" }, }, { @@ -52,12 +70,40 @@ lvim.plugins = { "MunifTanjim/nui.nvim", }, }, + -- load luasnips + cmp related in insert mode only + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { + -- snippet plugin + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + opts = { history = true, updateevents = "TextChanged,TextChangedI" }, + config = function(_, opts) + require("luasnip").config.set_config(opts) + require "configs.luasnip" + end, + }, + -- cmp sources plugins + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, + }, + { + "hrsh7th/cmp-nvim-lsp", + }, { "luckasRanarison/tailwind-tools.nvim", dependencies = { "nvim-treesitter/nvim-treesitter" }, }, { - 'kyazdani42/nvim-web-devicons' + "kyazdani42/nvim-web-devicons" }, { "mfussenegger/nvim-dap", @@ -83,7 +129,7 @@ lvim.plugins = { build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out" }, { - "NvChad/nvim-colorizer.lua" + 'NvChad/nvim-colorizer.lua', }, { "folke/neodev.nvim", opts = {} @@ -100,26 +146,18 @@ lvim.plugins = { enabled = vim.fn.has("nvim-0.10.0") == 1, }, { - 'windwp/nvim-autopairs', + "windwp/nvim-autopairs", event = "InsertEnter", config = true -- use opts = {} for passing setup options -- this is equalent to setup({}) function }, { - 'nvim-treesitter/nvim-treesitter', + "nvim-treesitter/nvim-treesitter", }, { - "rust-lang/rust.vim", - ft = "rust", - init = function () - vim.g.rustfmt_autosave = 1 - end - }, - { - 'mrcjkb/rustaceanvim', + "mrcjkb/rustaceanvim", version = '^4', -- Recommended - ft = "rust", lazy = false, -- This plugin is already lazy }, {