From c4f262a5043ede5e404653c8ad20c9d103d36128 Mon Sep 17 00:00:00 2001 From: c-my Date: Sat, 11 Feb 2023 21:50:44 +0800 Subject: [PATCH] migrate some plugins to Lazy --- README.md | 11 +- init.lua | 3 +- lazy-lock.json | 28 +++ lua/configs/keymaps.lua | 94 +++++---- lua/configs/lazy.lua | 24 +++ lua/configs/options.lua | 31 +-- lua/configs/plugins/autopairs.lua | 5 - lua/configs/plugins/better_escape.lua | 5 - lua/configs/plugins/bufferline.lua | 18 -- lua/configs/plugins/cmp.lua | 152 -------------- lua/configs/plugins/comment.lua | 3 - lua/configs/plugins/gitsigns.lua | 3 - lua/configs/plugins/indent_blankline.lua | 15 -- lua/configs/plugins/lsp_installer.lua | 62 ------ .../plugins/lsp_settings/sumneko_lua.lua | 12 -- lua/configs/plugins/lualine.lua | 40 ---- lua/configs/plugins/mason.lua | 12 -- lua/configs/plugins/mason_lspconfig.lua | 53 ----- lua/configs/plugins/null_ls.lua | 8 - lua/configs/plugins/nvimtree.lua | 27 --- lua/configs/plugins/packer.lua | 187 ------------------ lua/configs/plugins/toggleterm.lua | 62 ------ lua/configs/plugins/treesitter.lua | 6 - lua/plugins/autopairs.lua | 7 + lua/plugins/better_escape.lua | 8 + lua/plugins/cmp.lua | 183 +++++++++++++++++ lua/plugins/comment.lua | 5 + lua/plugins/gitsigns.lua | 6 + lua/plugins/indent_blankline.lua | 10 + lua/plugins/lsp.lua | 73 +++++++ lua/plugins/lualine.lua | 60 ++++++ lua/plugins/nvimtree.lua | 44 +++++ lua/plugins/symbols_outline.lua | 9 + lua/plugins/telescope.lua | 22 +++ lua/plugins/themes.lua | 9 + lua/plugins/toggleterm.lua | 14 ++ lua/plugins/treesitter.lua | 16 ++ 37 files changed, 598 insertions(+), 729 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/configs/lazy.lua delete mode 100644 lua/configs/plugins/autopairs.lua delete mode 100644 lua/configs/plugins/better_escape.lua delete mode 100644 lua/configs/plugins/bufferline.lua delete mode 100644 lua/configs/plugins/cmp.lua delete mode 100644 lua/configs/plugins/comment.lua delete mode 100644 lua/configs/plugins/gitsigns.lua delete mode 100644 lua/configs/plugins/indent_blankline.lua delete mode 100644 lua/configs/plugins/lsp_installer.lua delete mode 100644 lua/configs/plugins/lsp_settings/sumneko_lua.lua delete mode 100644 lua/configs/plugins/lualine.lua delete mode 100644 lua/configs/plugins/mason.lua delete mode 100644 lua/configs/plugins/mason_lspconfig.lua delete mode 100644 lua/configs/plugins/null_ls.lua delete mode 100644 lua/configs/plugins/nvimtree.lua delete mode 100644 lua/configs/plugins/packer.lua delete mode 100644 lua/configs/plugins/toggleterm.lua delete mode 100644 lua/configs/plugins/treesitter.lua create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/better_escape.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/indent_blankline.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/nvimtree.lua create mode 100644 lua/plugins/symbols_outline.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/themes.lua create mode 100644 lua/plugins/toggleterm.lua create mode 100644 lua/plugins/treesitter.lua diff --git a/README.md b/README.md index baae05f..447991b 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,10 @@ * Windows: `~/AppData/Local/nvim/` * Linux: `~/.config/nvim/` 2. Run `nvim` -3. Restart nvim after Packer Sync process - -**Note**: Make sure there is no file `plugin/packer_compiled.lua` before step2. ## Plugins -* [wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim) -* [lewis6991/impatient.nvim](https://github.com/lewis6991/impatient.nvim) +* [folke/lazy.nvim](https://github.com/folke/lazy.nvim) * [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) * [jiangmiao/auto-pairs](https://github.com/jiangmiao/auto-pairs) * [lukas-reineke/indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) @@ -44,7 +40,7 @@ - [x] LSP - [x] 调整配置文件缩进 -- [x] Packer Plugins 懒加载 +- [x] ~~Packer Plugins 懒加载~~ - [x] CMP snip换行后tab数量问题 - [x] CMP command 不区分大小写 - [x] CMP document border @@ -57,4 +53,5 @@ - [x] Luasnip 功能 - [x] LuaLine - [x] shift 块后保持选择 -- [ ] window resize 快捷键 +- [x] window resize 快捷键 +- [ ] nvimtree 抢占Lazy窗口焦点 diff --git a/init.lua b/init.lua index dcde8ea..441928d 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,3 @@ -pcall(require, 'impatient') require 'configs.options' require 'configs.keymaps' -require 'configs.plugins.packer' +require 'configs.lazy' diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..c348503 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "eab2c83a0207369900e92783f56990808082eac2" }, + "LuaSnip": { "branch": "master", "commit": "9bff06b570df29434a88f9c6a9cea3b21ca17208" }, + "better-escape.nvim": { "branch": "master", "commit": "6fed33809cde3b416087fc540ad9eb17ec470193" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "friendly-snippets": { "branch": "main", "commit": "80597f3ea824946c87fd29f82b5ed4f24ef473f3" }, + "gitsigns.nvim": { "branch": "main", "commit": "f29f0b22fd66c910b892aae3bc18a4872c002738" }, + "indent-blankline.nvim": { "branch": "master", "commit": "8299fe7703dfff4b1752aeed271c3b95281a952d" }, + "lazy.nvim": { "branch": "main", "commit": "4917222c7e5c924bf7471b72a5e2d3e661530b40" }, + "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7a97a77eee486ae152d2c559a459eda7c8aa12aa" }, + "mason.nvim": { "branch": "main", "commit": "47e9f6bc4c5bb3d6453949f07b8280c725ef7490" }, + "nvim-autopairs": { "branch": "master", "commit": "45ae3122a4c7744db41298b41f9f5a3f092123e6" }, + "nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" }, + "nvim-lspconfig": { "branch": "master", "commit": "27e6eb27f31d1ef41427e1008029284c02dc856f" }, + "nvim-tree.lua": { "branch": "master", "commit": "b712b82b0ca4eb402ced2d83f8082366989e43e0" }, + "nvim-treesitter": { "branch": "master", "commit": "f6df07be122de665fb363476cc3680c90f5bdf05" }, + "nvim-web-devicons": { "branch": "master", "commit": "4475fe5ffd32360fb6c351abbfee8d7529a511e6" }, + "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, + "toggleterm.nvim": { "branch": "main", "commit": "19aad0f41f47affbba1274f05e3c067e6d718e1e" }, + "tokyonight.nvim": { "branch": "main", "commit": "a0abe53df53616d13da327636cb0bcac3ea7f5af" } +} \ No newline at end of file diff --git a/lua/configs/keymaps.lua b/lua/configs/keymaps.lua index eeb918f..5310d2e 100644 --- a/lua/configs/keymaps.lua +++ b/lua/configs/keymaps.lua @@ -1,55 +1,77 @@ -local opts = { - silent = true -} +local function map(mode, lhs, rhs, opts) + opts = opts or {} + opts.silent = opts.silent ~= false + vim.keymap.set(mode, lhs, rhs, opts) +end -vim.keymap.set('', '', '', opts) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +map("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " -- Use ESC to turn off search highlighting -vim.keymap.set('n', '', ':noh', opts) +map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) -- Move in insert mode -vim.keymap.set('i', '', '', opts) -vim.keymap.set('i', '', '', opts) -vim.keymap.set('i', '', '', opts) -vim.keymap.set('i', '', '', opts) +map("i", "", "") +map("i", "", "") +map("i", "", "") +map("i", "", "") + -- Moving line -- == re-indents the line to suit its new position -- gc reselects the last visual block -- = re-indents the block -vim.keymap.set('n', '', ':m .+1==', opts) -vim.keymap.set('n', '', ':m .-2==', opts) -vim.keymap.set('i', '', ':m .+1==gi', opts) -vim.keymap.set('i', '', ':m .-2==gi', opts) -vim.keymap.set('v', '', ":m '>+1gv=gv", opts) -vim.keymap.set('v', '', ":m '<-2gv=gv", opts) +map("n", "", "m .+1==", { desc = "Move down" }) +map("n", "", "m .-2==", { desc = "Move up" }) +map("i", "", "m .+1==gi", { desc = "Move down" }) +map("i", "", "m .-2==gi", { desc = "Move up" }) +-- The colon(:) bellow cannot be replaced by +map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) -- Keep selecting visual block -vim.keymap.set('v', '<', '', '>gv', opts) +map("v", "<", "", ">gv") --- Navigating window -vim.keymap.set('n', '', 'h', opts) -vim.keymap.set('n', '', 'j', opts) -vim.keymap.set('n', '', 'k', opts) -vim.keymap.set('n', '', 'l', opts) +-- Add undo break-points +map("i", ",", ",u") +map("i", ".", ".u") +map("i", ";", ";u") --- Keymaps for NvimTree -vim.keymap.set('n', '', ':NvimTreeFindFileToggle ', opts) -vim.keymap.set('n', 'a', ':NvimTreeFocus ', opts) +-- save file +map({ "i", "v", "n", "s" }, "", "w", { desc = "Save file" }) +map({ "i", "v", "n", "s" }, "fs", "w", { desc = "Save file" }) --- Keymaps for Telescope -vim.keymap.set('n', 'ff', ':Telescope find_files ', opts) -vim.keymap.set('n', 'fg', ':Telescope live_grep ', opts) -vim.keymap.set('n', 'fb', ':Telescope buffers ', opts) -vim.keymap.set('n', 'fh', ':Telescope help_tags ', opts) + +-- Move to window using the hjkl keys +map("n", "", "h", { desc = "Go to left window" }) +map("n", "", "j", { desc = "Go to lower window" }) +map("n", "", "k", { desc = "Go to upper window" }) +map("n", "", "l", { desc = "Go to right window" }) + +-- Resize window using arrow keys +map("n", "", "resize +2", { desc = "Increase window height" }) +map("n", "", "resize -2", { desc = "Decrease window height" }) +map("n", "", "vertical resize -2", { desc = "Decrease window width" }) +map("n", "", "vertical resize +2", { desc = "Increase window width" }) + +-- split/delete windows +map("n", "ww", "p", { desc = "Other window" }) +map("n", "wd", "c", { desc = "Delete window" }) +map("n", "w|", "s", { desc = "Split window below" }) +map("n", "w-", "v", { desc = "Split window right" }) +map("n", "|", "s", { desc = "Split window below" }) +map("n", "-", "v", { desc = "Split window right" }) + + +-- quit +map("n", "qq", "qa", { desc = "Quit all" }) -- Keymaps for LSP -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions -vim.keymap.set('n', 'e', 'lua vim.diagnostic.open_float()', opts) -vim.keymap.set('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) -vim.keymap.set('n', ']d', 'lua vim.diagnostic.goto_next()', opts) -vim.keymap.set('n', 'q', 'lua vim.diagnostic.setloclist()', opts) +map("n", "e", "lua vim.diagnostic.open_float()") +map("n", "[d", "lua vim.diagnostic.goto_prev()") +map("n", "]d", "lua vim.diagnostic.goto_next()") +map("n", "q", "lua vim.diagnostic.setloclist()") diff --git a/lua/configs/lazy.lua b/lua/configs/lazy.lua new file mode 100644 index 0000000..4c39fb7 --- /dev/null +++ b/lua/configs/lazy.lua @@ -0,0 +1,24 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system( + {"git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release + lazypath}) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins") +-- { +-- "jose-elias-alvarez/null-ls.nvim", +-- config = function() +-- require("configs.plugins.null_ls") +-- end +-- }, +-- -- UI Plugins +-- { +-- "akinsho/bufferline.nvim", +-- tag = "*", +-- requires = "nvim-tree/nvim-web-devicons", +-- config = function() +-- require("configs.plugins.bufferline") +-- end +-- }} diff --git a/lua/configs/options.lua b/lua/configs/options.lua index 8eb036f..fe76148 100644 --- a/lua/configs/options.lua +++ b/lua/configs/options.lua @@ -1,31 +1,34 @@ vim.opt.clipboard = 'unnamedplus' -vim.opt.number = true -vim.opt.cursorline = true -vim.opt.numberwidth = 2 -vim.opt.wrap = false +vim.opt.confirm = true -- Confirm to save changes before exiting modified buffer +vim.opt.cursorline = true -- Enable highlighting of the current line vim.opt.fileencoding = 'utf-8' -vim.opt.mouse = 'a' -vim.opt.updatetime = 250 +vim.opt.list = true +vim.opt.mouse = 'a' -- Enable mouse mode +vim.opt.number = true +vim.opt.numberwidth = 2 +vim.opt.showmode = false -- Dont show mode since we have a statusline vim.opt.timeoutlen = 400 +vim.opt.undofile = true +vim.opt.updatetime = 250 +vim.opt.wrap = false -vim.opt.smartcase = true vim.opt.ignorecase = true vim.opt.pumheight = 13 +vim.opt.smartcase = true vim.opt.wildignorecase = true vim.opt.wildmenu = false -vim.opt.smartindent = true vim.opt.autoindent = true -vim.opt.smarttab = true vim.opt.expandtab = true -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 - +vim.opt.smartindent = true +vim.opt.smarttab = true +vim.opt.softtabstop = 4 +vim.opt.splitbelow = true -- Put new windows below current +vim.opt.splitright = true -- Put new windows right of current +vim.opt.tabstop = 4 vim.opt.termguicolors = true -vim.opt.splitbelow = true -vim.opt.splitright = true vim.opt.completeopt = 'menu,menuone,noinsert' vim.opt.shortmess = 'I' diff --git a/lua/configs/plugins/autopairs.lua b/lua/configs/plugins/autopairs.lua deleted file mode 100644 index 39284aa..0000000 --- a/lua/configs/plugins/autopairs.lua +++ /dev/null @@ -1,5 +0,0 @@ -local autopairs = require('nvim-autopairs') - -autopairs.setup({ - fast_wrap = {}, -}) diff --git a/lua/configs/plugins/better_escape.lua b/lua/configs/plugins/better_escape.lua deleted file mode 100644 index 5b60940..0000000 --- a/lua/configs/plugins/better_escape.lua +++ /dev/null @@ -1,5 +0,0 @@ -local escape = require('better_escape') - -escape.setup({ - mapping = { 'jk' }, -}) diff --git a/lua/configs/plugins/bufferline.lua b/lua/configs/plugins/bufferline.lua deleted file mode 100644 index 1053adc..0000000 --- a/lua/configs/plugins/bufferline.lua +++ /dev/null @@ -1,18 +0,0 @@ -local bufferline = require('bufferline') - -local opts = { - noremap = true, - silent = true -} - -vim.api.nvim_set_keymap('n', 'gb', ':BufferLinePick', opts) -vim.api.nvim_set_keymap('n', '', ':BufferLineCycleNext', opts) -vim.api.nvim_set_keymap('n', '', ':BufferLineCyclePrev', opts) - -bufferline.setup({ - options = { - offsets = { - { filetype = 'NvimTree', text = 'File Explorer', text_align = 'center' }, - }, - } -}) diff --git a/lua/configs/plugins/cmp.lua b/lua/configs/plugins/cmp.lua deleted file mode 100644 index 8fc6d92..0000000 --- a/lua/configs/plugins/cmp.lua +++ /dev/null @@ -1,152 +0,0 @@ -local cmp = require('cmp') - -local luasnip = require('luasnip') - -local cmp_autopairs = require('nvim-autopairs.completion.cmp') - -require("luasnip.loaders.from_vscode").lazy_load() - -local kind_icons = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "" -} - -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) - -vim.cmd [[highlight CmpItemAbbrDeprecated gui=strikethrough]] - -cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - luasnip.lsp_expand(args.body) - -- 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. - end - }, - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, vim_item) - vim_item.abbr = string.format('%s', vim_item.abbr) - vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) - - vim_item.menu = ({ - nvim_lsp = '[LSP]', - luasnip = '[Snippet]', - buffer = '[BUF]', - path = '[Path]' - })[entry.source.name] - - return vim_item - end - }, - mapping = { - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item({ - -- Select but noinsert - behavior = cmp.SelectBehavior.Select - }) - else - fallback() - end - end, { 'i', 'c', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item({ - behavior = cmp.SelectBehavior.Select - }) - else - fallback() - end - end, { 'i', 'c', 's' }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), -- d - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close() - }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.confirm() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.confirm({ - select = true - }) - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 'c', 's' }), - [''] = cmp.mapping(function(fallback) - if luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }) - }, - completion = { - -- Highlight first item - completeopt = 'menu,menuone,noinsert' - }, - window = { - documentation = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - } - }, - experimental = { - -- ghost_text = true - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'cmdline' }, - } -}) - -cmp.setup.cmdline(':', { - sources = { { - name = 'cmdline' - } } -}) - -cmp.setup.cmdline('/', { - sources = { { - name = 'buffer' - } } -}) diff --git a/lua/configs/plugins/comment.lua b/lua/configs/plugins/comment.lua deleted file mode 100644 index 18fdda0..0000000 --- a/lua/configs/plugins/comment.lua +++ /dev/null @@ -1,3 +0,0 @@ -local comment = require('Comment') - -comment.setup() diff --git a/lua/configs/plugins/gitsigns.lua b/lua/configs/plugins/gitsigns.lua deleted file mode 100644 index 8e96255..0000000 --- a/lua/configs/plugins/gitsigns.lua +++ /dev/null @@ -1,3 +0,0 @@ -local gitsigns = require('gitsigns') - -gitsigns.setup() diff --git a/lua/configs/plugins/indent_blankline.lua b/lua/configs/plugins/indent_blankline.lua deleted file mode 100644 index 87f95d1..0000000 --- a/lua/configs/plugins/indent_blankline.lua +++ /dev/null @@ -1,15 +0,0 @@ -local indent_blankline = require('indent_blankline') - -indent_blankline.setup({ - show_current_context = true, - show_current_context_start = true, - - filetype_exclude = { - 'lspinfo', - 'packer', - 'checkhealth', - 'help', - 'man', - 'NvimTree', - } -}) diff --git a/lua/configs/plugins/lsp_installer.lua b/lua/configs/plugins/lsp_installer.lua deleted file mode 100644 index 0a045a1..0000000 --- a/lua/configs/plugins/lsp_installer.lua +++ /dev/null @@ -1,62 +0,0 @@ -local lsp_installer = require('nvim-lsp-installer') - -lsp_installer.setup({ - ensure_installed = { 'sumneko_lua', 'jdtls' }, - automatic_installation = true, - ui = { - icons = { - server_installed = "✓", - server_pending = "➜", - server_uninstalled = "✗" - } - } -}) - - -local lspconfig = require('lspconfig') - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - local opts = { - noremap = true, - silent = true, - buffer = bufnr, - } - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) - vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - vim.keymap.set('n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.keymap.set('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.keymap.set('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.keymap.set('n', 'wl', - 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.keymap.set('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.keymap.set('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - vim.keymap.set('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()', opts) - vim.keymap.set('n', 'f', 'lua vim.lsp.buf.format {async = true}()', opts) -end - -lspconfig.sumneko_lua.setup({ - on_attach = on_attach, - settings = require('configs.plugins.lsp_settings.sumneko_lua'), - capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), - -}) - -lspconfig.jdtls.setup({ - on_attach = on_attach, - capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), -}) - -lspconfig.jedi_language_server.setup({ - on_attach = on_attach, - capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), -}) diff --git a/lua/configs/plugins/lsp_settings/sumneko_lua.lua b/lua/configs/plugins/lsp_settings/sumneko_lua.lua deleted file mode 100644 index c09c14a..0000000 --- a/lua/configs/plugins/lsp_settings/sumneko_lua.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.stdpath('config') .. '/lua'] = true, - }, - }, - } -} diff --git a/lua/configs/plugins/lualine.lua b/lua/configs/plugins/lualine.lua deleted file mode 100644 index 6cd03b1..0000000 --- a/lua/configs/plugins/lualine.lua +++ /dev/null @@ -1,40 +0,0 @@ -local lualine = require('lualine') - -local lsp_status = function() - if next(vim.lsp.buf_get_clients()) ~= nil then - return '' .. '' .. ' LSP' - else - return '' - end -end - - -lualine.setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = {}, - always_divide_middle = true, - globalstatus = true, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { lsp_status, 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = { 'nvim-tree', 'symbols-outline', 'toggleterm' }, -} diff --git a/lua/configs/plugins/mason.lua b/lua/configs/plugins/mason.lua deleted file mode 100644 index 7600feb..0000000 --- a/lua/configs/plugins/mason.lua +++ /dev/null @@ -1,12 +0,0 @@ -local mason = require("mason") - - -mason.setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) diff --git a/lua/configs/plugins/mason_lspconfig.lua b/lua/configs/plugins/mason_lspconfig.lua deleted file mode 100644 index 67661ed..0000000 --- a/lua/configs/plugins/mason_lspconfig.lua +++ /dev/null @@ -1,53 +0,0 @@ -local mason_lsp = require("mason-lspconfig") -local lspconfig = require('lspconfig') - -mason_lsp.setup({ - ensure_installed = { "sumneko_lua", "jdtls", "omnisharp" }, -}) - -local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) - vim.keymap.set("n", "f", function() vim.lsp.buf.format { async = true } end, bufopts) -end - -mason_lsp.setup_handlers({ - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn"t have - -- a dedicated handler. - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup({ - on_attach = on_attach, - }) - end, - -- Next, you can provide a dedicated handler for specific servers. - -- For example, a handler override for the `rust_analyzer`: - ["sumneko_lua"] = function() - lspconfig.sumneko_lua.setup({ - on_attach = on_attach, - settings = require('configs.plugins.lsp_settings.sumneko_lua'), - -- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), - }) - end - -- ["rust_analyzer"] = function () - -- require("rust-tools").setup {} - -- end -}) diff --git a/lua/configs/plugins/null_ls.lua b/lua/configs/plugins/null_ls.lua deleted file mode 100644 index 9e4f53c..0000000 --- a/lua/configs/plugins/null_ls.lua +++ /dev/null @@ -1,8 +0,0 @@ -local null_ls = require('null-ls') - -null_ls.setup({ - sources = { - -- null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.black, - } -}) diff --git a/lua/configs/plugins/nvimtree.lua b/lua/configs/plugins/nvimtree.lua deleted file mode 100644 index 889f3a4..0000000 --- a/lua/configs/plugins/nvimtree.lua +++ /dev/null @@ -1,27 +0,0 @@ -local nvimtree = require("nvim-tree") - -nvimtree.setup({ - -- open_on_tab = true, - tab = { - sync = { - open = true, - } - }, - diagnostics = { - enable = true, - show_on_dirs = false, - }, - renderer = { - indent_markers = { - enable = true, - }, - group_empty = true, - } -}) - -local function open_nvim_tree() - -- open the tree - require("nvim-tree.api").tree.open() -end - -vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/lua/configs/plugins/packer.lua b/lua/configs/plugins/packer.lua deleted file mode 100644 index 685ffc5..0000000 --- a/lua/configs/plugins/packer.lua +++ /dev/null @@ -1,187 +0,0 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - -return require("packer").startup({ - function(use) - use "wbthomason/packer.nvim" - -- My plugins here - use { "lewis6991/impatient.nvim" } - use { - "nvim-treesitter/nvim-treesitter", - event = { "BufRead", "BufNewFile" }, - config = function() - require("configs.plugins.treesitter") - end - } - use { - "windwp/nvim-autopairs", -- Can"t lazyloaded because cmp-related - config = function() - require("configs.plugins.autopairs") - end - } - use { - "lukas-reineke/indent-blankline.nvim", - event = { "BufRead" }, - config = function() - require("configs.plugins.indent_blankline") - end - } - use { - "numToStr/Comment.nvim", - event = { "BufRead", "BufNewFile" }, - config = function() - require("configs.plugins.comment") - end - } - use { - "lewis6991/gitsigns.nvim", - event = { "BufRead", "BufNewFile" }, - config = function() - require("configs.plugins.gitsigns") - end - -- tag = "release" -- To use the latest release - } - use { - "max397574/better-escape.nvim", - event = "InsertEnter", - config = function() - require("configs.plugins.better_escape") - end - } - - -- CMP plugins - use { - "hrsh7th/nvim-cmp", - config = function() - require("configs.plugins.cmp") - end - } - use { "hrsh7th/cmp-nvim-lsp" } - use { "hrsh7th/cmp-buffer" } - use { "hrsh7th/cmp-path" } - use { "hrsh7th/cmp-cmdline" } - use { "saadparwaiz1/cmp_luasnip" } -- Snippet compleetions - - -- Snippets - use { "L3MON4D3/LuaSnip" } -- Snippet engine - use { "rafamadriz/friendly-snippets" } -- Snippets collection - - -- LSP - use { - "williamboman/mason.nvim", - requires = { "neovim/nvim-lspconfig" }, - config = function() - require("configs.plugins.mason") - end - - } - use { - "williamboman/mason-lspconfig.nvim", - config = function() - require("configs.plugins.mason_lspconfig") - end - } - use { "jose-elias-alvarez/null-ls.nvim", - config = function() - require("configs.plugins.null_ls") - end - } - - -- UI Plugins - use { "nvim-tree/nvim-web-devicons" } - use { - "nvim-tree/nvim-tree.lua", - requires = { "nvim-tree/nvim-web-devicons" -- optional, for file icon - }, - config = function() - require("configs.plugins.nvimtree") - end - } - use { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", - requires = { { "nvim-lua/plenary.nvim" } } - } - use { - "akinsho/bufferline.nvim", - tag = "*", - requires = "nvim-tree/nvim-web-devicons", - config = function() - require("configs.plugins.bufferline") - end - } - use { - "nvim-lualine/lualine.nvim", - requires = { "kyazdani42/nvim-web-devicons" }, - config = function() - require("configs.plugins.lualine") - end, - opt = false - } - use { "simrat39/symbols-outline.nvim", - config = function() - vim.keymap.set("n", "l", ":SymbolsOutline", { silent = true }) - end, - } - use { - "akinsho/toggleterm.nvim", - config = function() - require("configs.plugins.toggleterm") - end - } - - -- Themes - use { - "catppuccin/nvim", - as = "catppuccin", - config = function() - vim.g.catppuccin_flavour = "mocha" -- latte, frappe, macchiato, mocha - local catppuccin = require("catppuccin") - catppuccin.setup() - vim.cmd [[colorscheme catppuccin]] - end - } - use { - "folke/tokyonight.nvim", - opt = true, - config = function() - vim.g.tokyonight_style = "night" - vim.cmd [[colorscheme tokyonight]] - end - } - use({ - "rose-pine/neovim", - opt = true, - as = "rose-pine", - tag = "v1.*", - config = function() - require("rose-pine").setup({ - ---@usage "main"|"moon" - dark_variant = "main", - }) - -- vim.cmd("colorscheme rose-pine") - end - }) - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if packer_bootstrap then - require("packer").sync() - end - end, - config = { - display = { - open_fn = require('packer.util').float, - } - } -}) diff --git a/lua/configs/plugins/toggleterm.lua b/lua/configs/plugins/toggleterm.lua deleted file mode 100644 index c3bf532..0000000 --- a/lua/configs/plugins/toggleterm.lua +++ /dev/null @@ -1,62 +0,0 @@ -local toggleterm = require("toggleterm") - -local shell = vim.o.shell - -if vim.loop.os_uname().sysname == 'Windows_NT' then - shell = 'powershell' -end - -toggleterm.setup({ - -- size can be a number or function which is passed the current terminal - -- size = 20 | function(term) - -- if term.direction == "horizontal" then - -- return 15 - -- elseif term.direction == "vertical" then - -- return vim.o.columns * 0.4 - -- end - -- end, - open_mapping = [[]], - -- on_open = fun(t: Terminal), -- function to run when the terminal opens - -- on_close = fun(t: Terminal), -- function to run when the terminal closes - -- on_stdout = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stdout - -- on_stderr = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stderr - -- on_exit = fun(t: Terminal, job: number, exit_code: number, name: string) -- function to run when terminal process exits - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_filetypes = {}, - -- highlights = { - -- -- highlights which map to a highlight group name and a table of it's values - -- -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split - -- Normal = { - -- guibg = , - -- }, - -- NormalFloat = { - -- link = 'Normal' - -- }, - -- FloatBorder = { - -- guifg = , - -- guibg = , - -- }, - -- }, - shade_terminals = true, - -- shading_factor = '', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals - persist_size = true, - -- direction = 'vertical' | 'horizontal' | 'tab' | 'float', - direction = 'float', - close_on_exit = true, -- close the terminal window when the process exits - shell = shell, -- change the default shell - -- This field is only relevant if direction is set to 'float' - float_opts = { - -- The border key is *almost* the same as 'nvim_open_win' - -- see :h nvim_open_win for details on borders however - -- the 'curved' border is a custom border type - -- not natively supported but implemented in this plugin. - -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open - border = 'single', - -- width = , - -- height = , - winblend = 3, - } -}) diff --git a/lua/configs/plugins/treesitter.lua b/lua/configs/plugins/treesitter.lua deleted file mode 100644 index c2e123d..0000000 --- a/lua/configs/plugins/treesitter.lua +++ /dev/null @@ -1,6 +0,0 @@ -require('nvim-treesitter.configs').setup({ - ensure_installed = { 'c', 'c_sharp', 'cpp', 'go', 'help', 'java', 'json', 'lua', 'python', 'vim' }, - highlight = { - enable = true, - } -}) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..c19dad6 --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return {{ + "windwp/nvim-autopairs", + event = {"InsertEnter"}, + opts = { + fast_wrap = {} + } +}} diff --git a/lua/plugins/better_escape.lua b/lua/plugins/better_escape.lua new file mode 100644 index 0000000..c3298b1 --- /dev/null +++ b/lua/plugins/better_escape.lua @@ -0,0 +1,8 @@ +return { + "max397574/better-escape.nvim", + event = "InsertEnter", + opts = { + mapping = {"jk", "jj"} + + } +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..8fff013 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,183 @@ +return { { + "hrsh7th/nvim-cmp", + version = false, -- last release is way too old + event = { "InsertEnter", -- + "CmdlineEnter" -- for enable cmp when typing command + }, + dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", "windwp/nvim-autopairs", { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end + } + } }, + opts = function() + local cmp = require("cmp") + local luasnip = require('luasnip') + + local kind_icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "ﰠ", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "" + } + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + return { + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + luasnip.lsp_expand(args.body) + -- 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. + end + }, + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + vim_item.abbr = string.format('%s', vim_item.abbr) + vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) + vim_item.menu = ({ + nvim_lsp = '[LSP]', + luasnip = '[Snippet]', + buffer = '[BUF]', + path = '[Path]', + })[entry.source.name] + + return vim_item + end + }, + mapping = { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item({ + -- Select but noinsert + behavior = cmp.SelectBehavior.Select + }) + else + fallback() + end + end, { 'i', 'c', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item({ + behavior = cmp.SelectBehavior.Select + }) + else + fallback() + end + end, { 'i', 'c', 's' }), + [''] = cmp.mapping.scroll_docs( -4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), -- d + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close() + }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm({ + select = true + }) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 'c', 's' }), + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable( -1) then + luasnip.jump( -1) + else + fallback() + end + end, { 'i', 's' }) + }, + completion = { + -- Highlight first item + completeopt = 'menu,menuone,noinsert' + }, + window = { + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" } + } + }, + experimental = { + ghost_text = { + hl_group = "LspCodeLens" + } + }, + sources = { { + name = 'nvim_lsp', + keyword_length = 1, + }, { + name = 'luasnip' + }, { + name = 'buffer' + }, { + name = 'path' + } } + } + end, + config = function(_, opts) + vim.cmd [[highlight CmpItemAbbrDeprecated gui=strikethrough]] + + local cmp = require("cmp") + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) -- Add parentheses after selecting function or method item + cmp.setup(opts) + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + end +} } diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..a5f47bf --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,5 @@ +return { + "numToStr/Comment.nvim", + event = {"BufRead", "BufNewFile"}, + config = true +} \ No newline at end of file diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..070bb0e --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,6 @@ +return { + "lewis6991/gitsigns.nvim", + event = {"BufRead", "BufNewFile"}, + config = true + -- tag = "release" -- To use the latest release +} diff --git a/lua/plugins/indent_blankline.lua b/lua/plugins/indent_blankline.lua new file mode 100644 index 0000000..583c1e2 --- /dev/null +++ b/lua/plugins/indent_blankline.lua @@ -0,0 +1,10 @@ +return {{ + "lukas-reineke/indent-blankline.nvim", + event = {"BufRead"}, + opts = { + show_current_context = true, + show_current_context_start = true, + + filetype_exclude = {'lspinfo', 'lazy', 'checkhealth', 'help', 'man', 'NvimTree'} + } +}} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..234f39a --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,73 @@ +return {{ + "williamboman/mason.nvim", + config = true +}, { + "williamboman/mason-lspconfig.nvim", + event = {"BufReadPre", "BufNewFile"}, + opts = { + ensure_installed = {"sumneko_lua", "jdtls", "omnisharp"} + }, + config = function(_, opts) + local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { + noremap = true, + silent = true, + buffer = bufnr + } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.format { + async = true + } + end, bufopts) + end + local lspconfig = require('lspconfig') + require("mason-lspconfig").setup(opts) + require("mason-lspconfig").setup_handlers { + + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup({ + on_attach = on_attach + }) + end, + + ["sumneko_lua"] = function() + lspconfig.sumneko_lua.setup({ + on_attach = on_attach, + settings = { + Lua = { + diagnostics = { + globals = {"vim"} + }, + workspace = { + library = { + [vim.fn.stdpath('config') .. '/lua'] = true + } + } + } + } + -- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + }) + end + } + end, + dependencies = {"neovim/nvim-lspconfig"} +}} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..dcd8f11 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,60 @@ +local lsp_status = function() + if next(vim.lsp.buf_get_clients()) ~= nil then + return "" .. "" .. " LSP" + else + return "" + end +end + +return {{ + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + dependencies = {"nvim-tree/nvim-web-devicons"}, + opts = { + options = { + icons_enabled = true, + theme = "auto", + component_separators = { + left = "", + right = "" + }, + section_separators = { + left = "", + right = "" + }, + disabled_filetypes = {"lazy"}, + always_divide_middle = true, + globalstatus = true + }, + sections = { + lualine_a = {"mode"}, + lualine_b = {"branch", "diff", "diagnostics"}, + lualine_c = {{ + "filetype", + icon_only = true, + separator = "", + padding = { + left = 1, + right = 0 + }, + icon = { + align = "right" + } + }, "filename"}, + lualine_x = {"searchcount", lsp_status, "encoding", "fileformat", "filetype"}, + lualine_y = {"progress"}, + lualine_z = {"location"} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {"filename"}, + lualine_x = {"location"}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {"nvim-tree", "symbols-outline", "toggleterm"} + } +}} + diff --git a/lua/plugins/nvimtree.lua b/lua/plugins/nvimtree.lua new file mode 100644 index 0000000..2d361fd --- /dev/null +++ b/lua/plugins/nvimtree.lua @@ -0,0 +1,44 @@ +return { + "nvim-tree/nvim-tree.lua", + dependencies = {"nvim-tree/nvim-web-devicons" -- optional, for file icon + }, + lazy = false, + opts = { + -- open_on_tab = true, + tab = { + sync = { + open = true + } + }, + diagnostics = { + enable = true, + show_on_dirs = false + }, + renderer = { + indent_markers = { + enable = true + }, + group_empty = true + } + }, + keys = {{ + '', + 'NvimTreeFindFileToggle ', + desc = "Nvimtree Toggle" + }, { + 'a', + 'NvimTreeFocus ', + desc = "Nvimtree Focus" + }}, + config = function() + require("nvim-tree").setup(opts) + local function open_nvim_tree() + -- open the tree + require("nvim-tree.api").tree.open() + end + vim.api.nvim_create_autocmd({"VimEnter"}, { + callback = open_nvim_tree + }) + + end +} diff --git a/lua/plugins/symbols_outline.lua b/lua/plugins/symbols_outline.lua new file mode 100644 index 0000000..4039482 --- /dev/null +++ b/lua/plugins/symbols_outline.lua @@ -0,0 +1,9 @@ +return { + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline", + keys = {{ + "cs", + "SymbolsOutline", + desc = "Symbols Outline" + }} +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..b3e3148 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,22 @@ +return {{ + "nvim-telescope/telescope.nvim", + dependencies = {"nvim-lua/plenary.nvim"}, + cmd = "Telescope", + keys = {{ + 'ff', + 'Telescope find_files ', + desc = "Find File" + }, { + 'fg', + 'Telescope live_grep ', + desc = "Find Grep" + }, { + 'fb', + 'Telescope buffers ', + desc = "Find Buffer" + }, { + 'fh', + 'Telescope help_tags ', + desc = "Find Help" + }} +}} diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua new file mode 100644 index 0000000..2fee197 --- /dev/null +++ b/lua/plugins/themes.lua @@ -0,0 +1,9 @@ +return {{ + "folke/tokyonight.nvim", + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + -- load the colorscheme here + vim.cmd([[colorscheme tokyonight]]) + end +}} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..194cd21 --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,14 @@ +local shell = vim.o.shell + +if vim.loop.os_uname().sysname == 'Windows_NT' then + shell = 'powershell' +end +return { { + "akinsho/toggleterm.nvim", + cmd = "ToggleTerm", + keys = { { "", "ToggleTerm", desc = "ToggleTerm" } }, + opts = { + open_mapping = [[]], + shell = shell + }, +} } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..8948794 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,16 @@ +return { + "nvim-treesitter/nvim-treesitter", + version = false, + build = ":TSUpdate", + event = {"BufReadPost", "BufNewFile"}, + opts = { + ensure_installed = {"c", "c_sharp", "cpp", "go", "help", "java", "json", "lua", "python", "vim"}, + highlight = { + enable = true + } + }, + ---@param opts TSConfig + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end +}