diff --git a/init.lua b/init.lua index 24e81c3..46c541c 100644 --- a/init.lua +++ b/init.lua @@ -5,20 +5,6 @@ local opt = vim.opt -- to set options local utils = require('utils') local packerUtil = require'packer.util' --------------------- PACKER -------------------------------- --- Auto install packer.nvim if not exists -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' -end -vim.cmd [[packadd packer.nvim]] -require('packer').init({ - snapshot_path = packerUtil.join_paths(vim.fn.stdpath('config'), 'snapshots'), - display = { - open_fn = require('packer.util').float, - } -}) -------------------- EXTERNAL ------------------------------ require('my_plugins') require('my_keymappings') @@ -26,7 +12,6 @@ require('my_options') require("my_autocommands") -- plugins -require('my_telescope') require('my_lspinstall') require('my_cmp') require('my_neogen') diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index 931f0dc..5cc01f3 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -1,3 +1,28 @@ +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerCompile + augroup end +]]) + +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 + packer_bootstrap = fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) +end +vim.api.nvim_command("packadd packer.nvim") + +function get_setup(name) + return string.format('require("setup/%s")', name) +end + return require('packer').startup(function() -- Packer can manage itself as an optional plugin @@ -7,10 +32,15 @@ return require('packer').startup(function() 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use { - 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}, {'kyazdani42/nvim-web-devicons'}} - } + use({ + 'nvim-telescope/telescope.nvim', + requires = { + {'nvim-lua/popup.nvim'}, + {'nvim-lua/plenary.nvim'}, + {'kyazdani42/nvim-web-devicons'} + }, + config = get_setup("telescope"), + }) use {'sainnhe/gruvbox-material'} use {'ellisonleao/gruvbox.nvim'} use {'lukas-reineke/indent-blankline.nvim'} @@ -24,10 +54,17 @@ return require('packer').startup(function() use { 'hrsh7th/nvim-cmp', requires = { - 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', - 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua', - 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', - 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji', 'hrsh7th/cmp-cmdline' + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-nvim-lsp', + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lua', + 'octaltree/cmp-look', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-calc', + 'f3fora/cmp-spell', + 'hrsh7th/cmp-emoji', + 'hrsh7th/cmp-cmdline' } } use {'rafamadriz/friendly-snippets'} diff --git a/lua/my_telescope.lua b/lua/setup/telescope.lua similarity index 95% rename from lua/my_telescope.lua rename to lua/setup/telescope.lua index 40ada92..ce222d4 100644 --- a/lua/my_telescope.lua +++ b/lua/setup/telescope.lua @@ -1,50 +1,50 @@ -local actions = require('telescope.actions') - -local mappingTab = { - i = { - [''] = actions.select_tab, - [''] = actions.select_default, - } -} - -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = actions.close, - [''] = actions.select_default + actions.center, - [''] = actions.send_selected_to_loclist, - [''] = actions.smart_send_to_qflist - } - } - }, - pickers = { - -- Your special builtin config goes in here - buffers = { - sort_lastused = true, - theme = 'ivy', - mappings = { - i = { - [''] = actions.delete_buffer, - [''] = actions.select_default, - }, - n = { - [''] = actions.delete_buffer, - } - } - }, - find_files = { - theme = 'ivy', - previewer = false, - }, - oldfiles = { - theme = 'ivy', - }, - git_files = { - theme = 'ivy', - previewer = false, - }, - lsp_dynamic_workspace_symbols = { - }, - } -} +local actions = require('telescope.actions') + +local mappingTab = { + i = { + [''] = actions.select_tab, + [''] = actions.select_default, + } +} + +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = actions.close, + [''] = actions.select_default + actions.center, + [''] = actions.send_selected_to_loclist, + [''] = actions.smart_send_to_qflist + } + } + }, + pickers = { + -- Your special builtin config goes in here + buffers = { + sort_lastused = true, + theme = 'ivy', + mappings = { + i = { + [''] = actions.delete_buffer, + [''] = actions.select_default, + }, + n = { + [''] = actions.delete_buffer, + } + } + }, + find_files = { + theme = 'ivy', + previewer = false, + }, + oldfiles = { + theme = 'ivy', + }, + git_files = { + theme = 'ivy', + previewer = false, + }, + lsp_dynamic_workspace_symbols = { + }, + } +}