From b8c03461bbe8de623654aa377f1e0f35ab517c5f Mon Sep 17 00:00:00 2001 From: Nikurasu Date: Fri, 23 Dec 2022 10:15:39 +0100 Subject: [PATCH] Rewrite Neovim config --- .gitignore | 1 + nvim/init.lua | 87 +++++++++------------------ nvim/init.lua.old | 85 ++++++++++++++++++++++++++ nvim/lua/keybindings/init.lua | 6 ++ nvim/lua/plugins/dashboard/init.lua | 1 + nvim/lua/plugins/lualine/init.lua | 7 +++ nvim/lua/plugins/nvim-tree/init.lua | 8 +++ nvim/lua/plugins/packer/init.lua | 40 ++++++++++++ nvim/lua/plugins/transparent/init.lua | 3 + nvim/lua/plugins/treesitter/init.lua | 12 ++++ shell/alias/alias | 2 + 11 files changed, 193 insertions(+), 59 deletions(-) create mode 100644 .gitignore create mode 100644 nvim/init.lua.old create mode 100644 nvim/lua/keybindings/init.lua create mode 100644 nvim/lua/plugins/dashboard/init.lua create mode 100644 nvim/lua/plugins/lualine/init.lua create mode 100644 nvim/lua/plugins/nvim-tree/init.lua create mode 100644 nvim/lua/plugins/packer/init.lua create mode 100644 nvim/lua/plugins/transparent/init.lua create mode 100644 nvim/lua/plugins/treesitter/init.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/nvim/init.lua b/nvim/init.lua index 59dece8..5d16eb1 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,3 +1,29 @@ +-- Bootstrap +local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' +local is_bootstrap = false +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + is_bootstrap = true + vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path } + vim.cmd [[packadd packer.nvim]] +end + +require('plugins.packer') + + +-- When we are bootstrapping a configuration, it doesn't +-- make sense to execute the rest of the init.lua. +-- +-- You'll need to restart nvim, and then it will work. +if is_bootstrap then + print '==================================' + print ' Plugins are being installed' + print ' Wait until Packer completes,' + print ' then restart nvim' + print '==================================' + return +end + +-- General Configuration vim.opt.number = true vim.opt.relativenumber = true vim.opt.ignorecase = true @@ -5,63 +31,6 @@ vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 vim.opt.expandtab = true -vim.cmd('colorscheme base16-material-darker') - -require("transparent").setup({ - enable = true, -}) - -require'nvim-treesitter.configs'.setup { - ensure_installed = { "vim", "c", "lua", "kotlin", "javascript", "typescript" }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - rainbow = { - enable = true, - extended_mode = true, - max_file_lines = nil, - } -} - -require("nvim-tree").setup({ - open_on_setup = true - -}) - -require('lualine').setup({ - options = { - theme = 'base16', - section_separators = { left = '', right = '' } - }, - extensions = {'nvim-tree'} -}) - - -return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' - use { - 'nvim-treesitter/nvim-treesitter', - run = function() - local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) - ts_update() - end, - } - use 'p00f/nvim-ts-rainbow' - use 'jiangmiao/auto-pairs' - use { - 'nvim-tree/nvim-tree.lua', - requires = { - 'nvim-tree/nvim-web-devicons', - } - } - use { - 'nvim-lualine/lualine.nvim', - requires = { - 'kyazdani42/nvim-web-devicons', - } - } - use 'RRethy/nvim-base16' - use 'xiyaowong/nvim-transparent' -end) +vim.cmd('colorscheme base16-tomorrow-night-eighties') +require('keybindings') \ No newline at end of file diff --git a/nvim/init.lua.old b/nvim/init.lua.old new file mode 100644 index 0000000..e570609 --- /dev/null +++ b/nvim/init.lua.old @@ -0,0 +1,85 @@ +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.ignorecase = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +vim.g.mapleader = ' ' + +vim.keymap.set('', 'tt', ':NvimTreeToggle') + +vim.keymap.set('n', 'bl', ':buffers') + +vim.cmd('colorscheme base16-material-darker') + +require("transparent").setup({ + enable = true, +}) + +require'nvim-treesitter.configs'.setup { + ensure_installed = { "vim", "c", "lua", "kotlin", "javascript", "typescript" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + } +} + +require("nvim-tree").setup({ + open_on_setup = false, + actions = { + open_file = { + quit_on_open = true, + } + } +}) + +vim.api.nvim_create_autocmd("BufEnter", { + nested = true, + callback = function() + if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then + vim.cmd "quit" + end + end +}) + +require('lualine').setup({ + options = { + theme = 'base16', + section_separators = { left = '', right = '' } + }, + extensions = {'nvim-tree'} +}) + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + } + use 'p00f/nvim-ts-rainbow' + use 'jiangmiao/auto-pairs' + use { + 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', + } + } + use { + 'nvim-lualine/lualine.nvim', + requires = { + 'kyazdani42/nvim-web-devicons', + } + } + use 'RRethy/nvim-base16' + use 'xiyaowong/nvim-transparent' +end) + diff --git a/nvim/lua/keybindings/init.lua b/nvim/lua/keybindings/init.lua new file mode 100644 index 0000000..6effb0f --- /dev/null +++ b/nvim/lua/keybindings/init.lua @@ -0,0 +1,6 @@ +vim.g.mapleader = ' ' + +vim.keymap.set('', 'ft', ':NvimTreeToggle') +vim.keymap.set('', 'ff', ':NvimTreeFocus') + +vim.keymap.set('n', 'bl', ':buffers') \ No newline at end of file diff --git a/nvim/lua/plugins/dashboard/init.lua b/nvim/lua/plugins/dashboard/init.lua new file mode 100644 index 0000000..5b5cc43 --- /dev/null +++ b/nvim/lua/plugins/dashboard/init.lua @@ -0,0 +1 @@ +local db = require('dashboard') \ No newline at end of file diff --git a/nvim/lua/plugins/lualine/init.lua b/nvim/lua/plugins/lualine/init.lua new file mode 100644 index 0000000..5ce48b8 --- /dev/null +++ b/nvim/lua/plugins/lualine/init.lua @@ -0,0 +1,7 @@ +require('lualine').setup({ + options = { + theme = 'base16', + section_separators = { left = '', right = '' } + }, + extensions = {'nvim-tree'} + }) \ No newline at end of file diff --git a/nvim/lua/plugins/nvim-tree/init.lua b/nvim/lua/plugins/nvim-tree/init.lua new file mode 100644 index 0000000..db5c1d9 --- /dev/null +++ b/nvim/lua/plugins/nvim-tree/init.lua @@ -0,0 +1,8 @@ +require("nvim-tree").setup({ + open_on_setup = false, + actions = { + open_file = { + quit_on_open = true, + } + } + }) \ No newline at end of file diff --git a/nvim/lua/plugins/packer/init.lua b/nvim/lua/plugins/packer/init.lua new file mode 100644 index 0000000..fc5ca39 --- /dev/null +++ b/nvim/lua/plugins/packer/init.lua @@ -0,0 +1,40 @@ +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use { + 'glepnir/dashboard-nvim', + config = [[require('plugins.dashboard')]] + } + use { + 'nvim-lualine/lualine.nvim', + requires = { + 'kyazdani42/nvim-web-devicons', + 'RRethy/nvim-base16' + }, + config = [[require('plugins.lualine')]] + } + use { + 'xiyaowong/nvim-transparent', + config = [[require('plugins.transparent')]] + } + use { + 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', + }, + config = [[require('plugins.nvim-tree')]] + } + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + config = [[require('plugins.treesitter')]] + } + use 'p00f/nvim-ts-rainbow' + use 'jiangmiao/auto-pairs' + + if is_bootstrap then + require('packer').sync() + end +end) \ No newline at end of file diff --git a/nvim/lua/plugins/transparent/init.lua b/nvim/lua/plugins/transparent/init.lua new file mode 100644 index 0000000..6e1e360 --- /dev/null +++ b/nvim/lua/plugins/transparent/init.lua @@ -0,0 +1,3 @@ +require("transparent").setup({ + enable = true, + }) \ No newline at end of file diff --git a/nvim/lua/plugins/treesitter/init.lua b/nvim/lua/plugins/treesitter/init.lua new file mode 100644 index 0000000..7821587 --- /dev/null +++ b/nvim/lua/plugins/treesitter/init.lua @@ -0,0 +1,12 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { "vim", "c", "lua", "kotlin", "javascript", "typescript" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + } + } \ No newline at end of file diff --git a/shell/alias/alias b/shell/alias/alias index ebc934c..d08b7c2 100644 --- a/shell/alias/alias +++ b/shell/alias/alias @@ -4,3 +4,5 @@ alias ytm-album="yt-dlp -x --audio-format opus -f 251 -o \"%(playlist_index)s_%( # copy public ip alias cpip="curl ifconfig.me | pbcopy" +# Install Nvim Packer Plugins without opening nvim +alias packerSync="nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'"