From 6a2c2ddc6114fb2541ad0d0586103551a06bad87 Mon Sep 17 00:00:00 2001 From: "dedal.qq" Date: Tue, 19 Nov 2024 00:30:27 +0300 Subject: [PATCH] commit --- .gitignore | 1 + init.lua | 1 - lua/config/keymaping.lua | 7 +- lua/config/lazy.lua | 40 ++++++------ lua/config/options.lua | 2 + lua/plugins/barbar.lua | 5 ++ lua/plugins/conform.lua | 4 +- lua/plugins/lsp.lua | 77 +++++++++++----------- lua/plugins/lualine.lua | 10 +-- lua/plugins/neo-tree.lua | 16 ++--- lua/plugins/nvim-cmp.lua | 134 +++++++++++++++++++------------------- lua/plugins/onedark.lua | 8 +-- lua/plugins/telescope.lua | 16 ++--- 13 files changed, 165 insertions(+), 156 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/init.lua b/init.lua index e3c2c03..3cad6b5 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,3 @@ require("config.lazy") require("config.options") require("config.keymaping") - diff --git a/lua/config/keymaping.lua b/lua/config/keymaping.lua index 3310a0b..179a3f6 100644 --- a/lua/config/keymaping.lua +++ b/lua/config/keymaping.lua @@ -1,8 +1,11 @@ local map = vim.keymap.set +-- neo-tree map("n", "e", ":Neotree", { desc = "nvimtree focus window" }) -- telescope -map("n", "ff", "Telescope live_grep", { desc = "telescope live grep" }) -map("n", "gr", "Telescope lsp_references", { desc = "telescope lsp references" }) +map("n", "ff", ":Telescope live_grep", { desc = "telescope live grep" }) +map("n", "gr", ":Telescope lsp_references", { desc = "telescope lsp references" }) +map("n", "", ":BufferNext", { desc = "Next tab" }) +map("n", "", ":BufferPrevious", { desc = "Previous tab" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index f5ee74c..c381a4b 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -1,17 +1,17 @@ -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) @@ -23,13 +23,13 @@ vim.g.maplocalleader = "\\" -- Setup lazy.nvim require("lazy").setup({ - spec = { - -- import your plugins - { import = "plugins" }, - }, - -- Configure any other settings here. See the documentation for more details. - -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "habamax" } }, - -- automatically check for plugin updates - checker = { enabled = true }, + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, }) diff --git a/lua/config/options.lua b/lua/config/options.lua index cf6a669..c865066 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -4,6 +4,8 @@ local g = vim.g g.mapleader = " " +opt.tabstop = 4 + o.laststatus = 3 o.showmode = false diff --git a/lua/plugins/barbar.lua b/lua/plugins/barbar.lua index 54449d4..fde92fb 100644 --- a/lua/plugins/barbar.lua +++ b/lua/plugins/barbar.lua @@ -12,6 +12,11 @@ return { opts = { -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: animation = true, + gitsigns = { + added = { enabled = true, icon = "+" }, + changed = { enabled = true, icon = "~" }, + deleted = { enabled = true, icon = "-" }, + }, insert_at_start = true, auto_hide = true, sidebar_filetypes = { diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 6de2243..df0ccdc 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -1,3 +1,5 @@ +local api = vim.api + return { "stevearc/conform.nvim", --opts = {}, @@ -8,7 +10,7 @@ return { }, }) - vim.api.nvim_create_autocmd("BufWritePre", { + api.nvim_create_autocmd("BufWritePre", { pattern = "*", callback = function(args) require("conform").format({ bufnr = args.buf }) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index d7fb2b5..c51da26 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,50 +1,47 @@ return { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', + -- Main LSP Configuration + "neovim/nvim-lspconfig", - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - { - 'williamboman/mason.nvim', config = true, - }, -- NOTE: Must be loaded before dependants - 'williamboman/mason-lspconfig.nvim', - --'WhoIsSethDaniel/mason-tool-installer.nvim', - --{ 'j-hui/fidget.nvim', opts = {} }, - 'hrsh7th/cmp-nvim-lsp', - }, - - config = function() - --local capabilities = vim.lsp.protocol.make_client_capabilities() - --capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + { + "williamboman/mason.nvim", + config = true, + }, -- NOTE: Must be loaded before dependants + "williamboman/mason-lspconfig.nvim", + --'WhoIsSethDaniel/mason-tool-installer.nvim', + --{ 'j-hui/fidget.nvim', opts = {} }, + "hrsh7th/cmp-nvim-lsp", + }, - local servers = { - gopls = {}, - } + config = function() + --local capabilities = vim.lsp.protocol.make_client_capabilities() + --capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - require('mason').setup() + local servers = { + gopls = {}, + } - --local ensure_installed = vim.tbl_keys(servers or {}) - --vim.list_extend(ensure_installed, { - -- 'stylua', -- Used to format Lua code - --}) + require("mason").setup() - --require('mason-tool-installer').setup { ensure_installed = ensure_installed } + --local ensure_installed = vim.tbl_keys(servers or {}) + --vim.list_extend(ensure_installed, { + -- 'stylua', -- Used to format Lua code + --}) - require('mason-lspconfig').setup { - handlers = { - function(server_name) + --require('mason-tool-installer').setup { ensure_installed = ensure_installed } - local capabilities = require('cmp_nvim_lsp').default_capabilities() + require("mason-lspconfig").setup({ + handlers = { + function(server_name) + local capabilities = require("cmp_nvim_lsp").default_capabilities() - - - local server = servers[server_name] or {} - server.capabilities = capabilities - -- server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, + local server = servers[server_name] or {} + server.capabilities = capabilities + -- server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, } - diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 3c1da48..ff23b26 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,7 +1,7 @@ return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - require('lualine').setup() - end + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup() + end, } diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index 25bd2a4..8bf9ff3 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -1,10 +1,10 @@ return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information - } + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, } diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua index 8bfff8c..0753f06 100644 --- a/lua/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -1,71 +1,71 @@ return { - "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 "nvchad.configs.luasnip" - -- end, - --}, + "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 "nvchad.configs.luasnip" + -- end, + --}, - -- autopairing of (){}[] etc - --{ - -- "windwp/nvim-autopairs", - -- opts = { - -- fast_wrap = {}, - -- disable_filetype = { "TelescopePrompt", "vim" }, - -- }, - -- config = function(_, opts) - -- require("nvim-autopairs").setup(opts) --- - -- setup cmp for autopairs - -- local cmp_autopairs = require "nvim-autopairs.completion.cmp" - -- require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) - -- end, - -- }, + -- autopairing of (){}[] etc + --{ + -- "windwp/nvim-autopairs", + -- opts = { + -- fast_wrap = {}, + -- disable_filetype = { "TelescopePrompt", "vim" }, + -- }, + -- config = function(_, opts) + -- require("nvim-autopairs").setup(opts) + -- + -- setup cmp for autopairs + -- local cmp_autopairs = require "nvim-autopairs.completion.cmp" + -- require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + -- end, + -- }, - -- cmp sources plugins - --{ - -- "saadparwaiz1/cmp_luasnip", - --"hrsh7th/cmp-nvim-lua", - -- "hrsh7th/cmp-nvim-lsp", - -- "hrsh7th/cmp-buffer", - -- "hrsh7th/cmp-path", - -- }, - }, - config = function() - local cmp = require('cmp') --- snippet = { - -- REQUIRED - you must specify a snippet engine - -- expand = function(args) - -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) - --end, - --}, + -- cmp sources plugins + --{ + -- "saadparwaiz1/cmp_luasnip", + --"hrsh7th/cmp-nvim-lua", + -- "hrsh7th/cmp-nvim-lsp", + -- "hrsh7th/cmp-buffer", + -- "hrsh7th/cmp-path", + -- }, + }, + config = function() + local cmp = require("cmp") + -- snippet = { + -- REQUIRED - you must specify a snippet engine + -- expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) + --end, + --}, - cmp.setup({ - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), -[''] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - }), - }) - end - --opts = function() - -- return require "nvchad.configs.cmp" - --end, - } + cmp.setup({ + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + }), + }) + end, + --opts = function() + -- return require "nvchad.configs.cmp" + --end, +} diff --git a/lua/plugins/onedark.lua b/lua/plugins/onedark.lua index c372587..82bea54 100644 --- a/lua/plugins/onedark.lua +++ b/lua/plugins/onedark.lua @@ -1,6 +1,6 @@ return { - "navarasu/onedark.nvim", - config = function() - require('onedark').load() - end, + "navarasu/onedark.nvim", + config = function() + require("onedark").load() + end, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 560ea94..9f4059f 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,8 +1,8 @@ -return { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - -- cmd = "Telescope", - opts = function() - -- return require "nvchad.configs.telescope" - end, - } +return { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + -- cmd = "Telescope", + opts = function() + -- return require "nvchad.configs.telescope" + end, +}