From daaab2caad4faf1e4a846861147627d071c3c68e Mon Sep 17 00:00:00 2001 From: Saeed Afzal Date: Sat, 24 Sep 2022 14:56:23 +0100 Subject: [PATCH] Update configuration --- lua/core/init.lua | 5 ++ lua/plugins/barbar_nvimtree.lua | 14 ++- lua/plugins/config/barbar.lua | 3 + lua/plugins/config/catppuccin.lua | 14 --- lua/plugins/config/colorizer.lua | 3 +- lua/plugins/config/lspsetup.lua | 8 +- lua/plugins/config/lualine.lua | 6 +- lua/plugins/config/nvimtree.lua | 21 +++-- lua/plugins/config/tokyonight.lua | 7 +- lua/plugins/config/treesitter.lua | 10 +-- lua/plugins/config/whichkey.lua | 88 ++++++++----------- lua/plugins/init.lua | 10 --- lua/plugins/setup.lua | 141 ++++++++++++++++-------------- 13 files changed, 154 insertions(+), 176 deletions(-) create mode 100644 lua/plugins/config/barbar.lua delete mode 100644 lua/plugins/config/catppuccin.lua diff --git a/lua/core/init.lua b/lua/core/init.lua index c20b77a..e269f3b 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,6 +1,11 @@ local opt = vim.opt local g = vim.g +-- Disable +g.loaded = 1 +g.loaded_netrwPlugin = 1 + +-- Settings g.mapleader = " " opt.backup = false diff --git a/lua/plugins/barbar_nvimtree.lua b/lua/plugins/barbar_nvimtree.lua index 14c171d..c1447cb 100644 --- a/lua/plugins/barbar_nvimtree.lua +++ b/lua/plugins/barbar_nvimtree.lua @@ -1,10 +1,18 @@ local nvim_tree_events = require("nvim-tree.events") local bufferline_state = require("bufferline.state") -nvim_tree_events.on_tree_open(function() - bufferline_state.set_offset(31, "File Tree") +local function get_tree_size() + return require"nvim-tree.view".View.width +end + +nvim_tree_events.subscribe("TreeOpen", function() + bufferline_state.set_offset(get_tree_size()) end) -nvim_tree_events.on_tree_close(function() +nvim_tree_events.subscribe("Resize", function() + bufferline_state.set_offset(get_tree_size()) +end) + +nvim_tree_events.subscribe("TreeClose", function() bufferline_state.set_offset(0) end) diff --git a/lua/plugins/config/barbar.lua b/lua/plugins/config/barbar.lua new file mode 100644 index 0000000..945acb5 --- /dev/null +++ b/lua/plugins/config/barbar.lua @@ -0,0 +1,3 @@ +require("bufferline").setup { + maximum_length = 25 +} diff --git a/lua/plugins/config/catppuccin.lua b/lua/plugins/config/catppuccin.lua deleted file mode 100644 index bbc1f7d..0000000 --- a/lua/plugins/config/catppuccin.lua +++ /dev/null @@ -1,14 +0,0 @@ -vim.g.catppuccin_flavour = "mocha" - -require("catppuccin").setup { - styles = { - loops = { "italic" }, - functions = { "italic", "bold" } - }, - - integrations = { - lsp_trouble = true, - which_key = true, - barbar = true - } -} diff --git a/lua/plugins/config/colorizer.lua b/lua/plugins/config/colorizer.lua index 900c78e..6632c39 100644 --- a/lua/plugins/config/colorizer.lua +++ b/lua/plugins/config/colorizer.lua @@ -9,4 +9,5 @@ require("colorizer").setup( hsl_fn = true, css = true, css_fn = true -}) + } +) diff --git a/lua/plugins/config/lspsetup.lua b/lua/plugins/config/lspsetup.lua index 049ef03..6aa0c8a 100644 --- a/lua/plugins/config/lspsetup.lua +++ b/lua/plugins/config/lspsetup.lua @@ -1,11 +1,5 @@ require("lsp-setup").setup { servers = { - sumneko_lua = {}, - tsserver = {}, - gopls = {}, - cssls = {}, - jsonls = {}, - html = {}, - pylsp = {} + sumneko_lua = {} } } diff --git a/lua/plugins/config/lualine.lua b/lua/plugins/config/lualine.lua index c1c495c..5596741 100644 --- a/lua/plugins/config/lualine.lua +++ b/lua/plugins/config/lualine.lua @@ -1,10 +1,12 @@ require("lualine").setup { options = { - theme = "catppuccin" + theme = "tokyonight" }, extensions = { "nvim-tree", - "toggleterm" + "fzf", + "toggleterm", + "symbols-outline" } } diff --git a/lua/plugins/config/nvimtree.lua b/lua/plugins/config/nvimtree.lua index 7a3f56d..0c8cb40 100644 --- a/lua/plugins/config/nvimtree.lua +++ b/lua/plugins/config/nvimtree.lua @@ -1,17 +1,12 @@ require("nvim-tree").setup { - disable_netrw = true, - create_in_closed_folder = true, - hijack_cursor = true, - update_cwd = true, - - view = { - hide_root_folder = true - }, + -- view = { + -- hide_root_folder = true + -- }, renderer = { - highlight_git = true, - highlight_opened_files = "all", group_empty = true, + highlight_git = true, + indent_markers = { enable = true } @@ -19,10 +14,14 @@ require("nvim-tree").setup { update_focused_file = { enable = true, - update_cwd = true + update_root = true }, diagnostics = { enable = true + }, + + filters = { + custom = { ".git" } } } diff --git a/lua/plugins/config/tokyonight.lua b/lua/plugins/config/tokyonight.lua index 6d7b9bb..0fcf810 100644 --- a/lua/plugins/config/tokyonight.lua +++ b/lua/plugins/config/tokyonight.lua @@ -1,3 +1,6 @@ -local g = vim.g +require("tokyonight").setup { + style = "night", + lualine_bold = true +} -vim.g.tokyonight_italic_functions = true +vim.cmd [[colorscheme tokyonight]] diff --git a/lua/plugins/config/treesitter.lua b/lua/plugins/config/treesitter.lua index 9003ba3..989a12a 100644 --- a/lua/plugins/config/treesitter.lua +++ b/lua/plugins/config/treesitter.lua @@ -1,11 +1,3 @@ require("nvim-treesitter.configs").setup { - ensure_installed = { "lua", "bash", "cpp", "css", "go", "gomod", "html", "javascript", "json", "make", "python", "typescript" }, - - highlight = { - enable = true - }, - - matchup = { - enable = true - } + ensure_installed = { "lua", "go", "typescript" } } diff --git a/lua/plugins/config/whichkey.lua b/lua/plugins/config/whichkey.lua index 8dc682a..8a71144 100644 --- a/lua/plugins/config/whichkey.lua +++ b/lua/plugins/config/whichkey.lua @@ -1,8 +1,7 @@ local wk = require("which-key") wk.setup { - -- TODO: Change to true - ignore_missing = false, + ignore_missing = true, key_labels = { [""] = "SPC" } @@ -10,62 +9,49 @@ wk.setup { wk.register({ [""] = { - -- Files - [""] = { "Telescope fd", "find files" }, - - -- Buffers - b = { - name = "buffers", - x = { "BufferClose", "close buffer" }, - n = { "BufferMoveNext", "move next" }, - m = { "BufferMovePrevious", "move previous" }, - f = { "Telescope current_buffer_fuzzy_find", "find in current buffer" }, - - p = { - name = "pinned buffers", - p = { "BufferPin", "pin buffer" }, - x = { "BufferCloseAllButPinned", "close all but pinned" } - } - }, - - -- Telescope - t = { - name = "Telescope", + f = { + name = "Find", + f = { "Telescope fd", "find file" }, w = { "Telescope live_grep", "live grep" }, - b = { "Telescope buffers", "Buffers" }, - k = { "Telescope keymaps", "Keymaps" }, - t = { "TodoTelescope", "Todos" }, - c = { "TodoTelescope", "" }, - ["."] = { "Telescope keymaps", "Global Keymaps" } + b = { "Telescope buffers", "all buffers" }, + t = { "TodoTelescope", "todos" }, + ["."] = { "Telescope keymaps", "keymaps" } }, - -- Git - g = { - name = "Git", - b = { "Gitsigns blame_line", "Blame Line" }, - d = { "Gitsigns diffthis", "Diff" } - }, - - -- LSP l = { name = "LSP", - a = { "vim.lsp.buf.code_action()", "Code Action" }, - f = { "vim.lsp.buf.formatting()", "Format" }, - n = { "vim.lsp.buf.rename()", "Rename" } - } + r = { "lua vim.lsp.buf.rename()", "rename" }, + d = { "Telescope diagnostics", "diagnostics" } + }, + + b = { + name = "Buffer", + p = { "BufferPick", "pick buffer" } + }, + + g = { + name = "Git", + b = { "Gitsigns blame_line", "blame line" }, + d = { "Gitsigns diffthis", "diff" }, + s = { "Telescope git_status", "git status" }, + c = { "Telescope git_commits", "commits" } + }, + + x = { "BufferClose", "close buffer" }, + r = { "NvimTreeRefresh", "refresh tree" }, + c = { "Telescope colorscheme", "colorscheme" }, + s = { "SymbolsOutline", "symbols outline" } }, - -- NvimTree - [""] = { "NvimTreeToggle", "NvimTree Toggle" }, + t = { + name = "Trouble", + t = { "TroubleToggle", "toggle trouble" } + }, + + -- Nvim Tree + [""] = { "NvimTreeToggle", "toggle nvimtree" }, -- Switching Buffers - [""] = { "BufferNext", "Next Buffer" }, - [""] = { "BufferPrevious", "Previous Buffer" }, - - -- Trouble - ["t"] = { - name = "Trouble", - t = { "TroubleToggle", "Trouble Toggle" }, - d = { "TodoTrouble", "Todos" } - } + [""] = { "BufferNext", "next buffer" }, + [""] = { "BufferPrevious", "previous buffer" } }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 9b261cd..69593ab 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,12 +1,2 @@ -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 }) - print("Installing packer: close and reopen Neovim...") -end - require("plugins.setup") require("plugins.barbar_nvimtree") - -vim.cmd [[colorscheme catppuccin]] diff --git a/lua/plugins/setup.lua b/lua/plugins/setup.lua index 592f688..01be816 100644 --- a/lua/plugins/setup.lua +++ b/lua/plugins/setup.lua @@ -1,4 +1,25 @@ -require("packer").startup(function(use) +-- Install packer for the first time +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() + +-- Safely load packer +local ok, packer = pcall(require, "packer") +if not ok then + return +end + +-- Setup the plugins +return packer.startup(function(use) use "wbthomason/packer.nvim" use "nvim-lua/plenary.nvim" use "nathom/filetype.nvim" @@ -10,18 +31,21 @@ require("packer").startup(function(use) end } + use "kyazdani42/nvim-web-devicons" + use { - "catppuccin/nvim", - as = "catppuccin", + "kyazdani42/nvim-tree.lua", + requires = "kyazdani42/nvim-web-devicons", config = function() - require("plugins.config.catppuccin") + require("plugins.config.nvimtree") end } use { - "kyazdani42/nvim-web-devicons", + "romgrk/barbar.nvim", + requires = "kyazdani42/nvim-web-devicons", config = function() - require("nvim-web-devicons").setup() + require("plugins.config.barbar") end } @@ -33,23 +57,6 @@ require("packer").startup(function(use) end } - use { - "andymass/vim-matchup", - after = "nvim-treesitter" - } - - use { - "norcalli/nvim-colorizer.lua", - config = function() - require("plugins.config.colorizer") - end - } - - use { - "romgrk/barbar.nvim", - requires = "kyazdani42/nvim-web-devicons" - } - use { "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true }, @@ -59,10 +66,9 @@ require("packer").startup(function(use) } use { - "kyazdani42/nvim-tree.lua", - requires = "kyazdani42/nvim-web-devicons", + "norcalli/nvim-colorizer.lua", config = function() - require("plugins.config.nvimtree") + require("plugins.config.colorizer") end } @@ -80,31 +86,16 @@ require("packer").startup(function(use) end } - use "JoosepAlviste/nvim-ts-context-commentstring" - use { "numToStr/Comment.nvim", - requires = "JoosepAlviste/nvim-ts-context-commentstring", config = function() require("Comment").setup() end } - use { - "nvim-telescope/telescope-fzf-native.nvim", - run = "make" - } - - use { - "nvim-telescope/telescope.nvim", - requires = "nvim-lua/plenary.nvim", - config = function() - require("plugins.config.telescope") - end - } - use { "akinsho/toggleterm.nvim", + tag = "*", config = function() require("plugins.config.toggleterm") end @@ -118,14 +109,21 @@ require("packer").startup(function(use) end } + -- Telescope use { - "folke/which-key.nvim", + "nvim-telescope/telescope-fzf-native.nvim", + run = "make" + } + + use { + "nvim-telescope/telescope.nvim", + requires = "nvim-lua/plenary.nvim", config = function() - require("plugins.config.whichkey") + require("plugins.config.telescope") end } - -- NOTE: LSP + -- LSP use { "junnplus/nvim-lsp-setup", requires = { @@ -139,36 +137,33 @@ require("packer").startup(function(use) } use { - "ray-x/lsp_signature.nvim", - after = "nvim-lspconfig", + "hrsh7th/nvim-cmp", + requires = { + "L3MON4D3/LuaSnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-cmdline" + }, config = function() - require("lsp_signature").setup() + require("plugins.config.cmp") end } - use { - "L3MON4D3/LuaSnip", - "saadparwaiz1/cmp_luasnip" - } - - use { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - { - "hrsh7th/nvim-cmp", - config = function() - require("plugins.config.cmp") - end - } - } - use { "rafamadriz/friendly-snippets", event = "InsertCharPre" } + use { + "ray-x/lsp_signature.nvim", + after = "nvim-lspconfig", + config = function() + require("lsp_signature").setup() + end + } + use { "windwp/nvim-autopairs", config = function() @@ -192,6 +187,20 @@ require("packer").startup(function(use) end } + use { + "simrat39/symbols-outline.nvim", + config = function() + require("symbols-outline").setup() + end + } + + use { + "folke/which-key.nvim", + config = function() + require("plugins.config.whichkey") + end + } + if packer_bootstrap then require("packer").sync() end