From 0a4a1a83e4ea1c50a22c8e830193911e52c65ff9 Mon Sep 17 00:00:00 2001 From: manobann Date: Mon, 17 Apr 2023 21:13:37 +0200 Subject: [PATCH] added bunch of configs --- init.lua | 313 +++++++++++++++++++++++++++++++- lua/custom/plugins/filetree.lua | 15 ++ lua/custom/plugins/init.lua | 4 + 3 files changed, 325 insertions(+), 7 deletions(-) create mode 100644 lua/custom/plugins/filetree.lua diff --git a/init.lua b/init.lua index 1cfa228b..1fd0d337 100644 --- a/init.lua +++ b/init.lua @@ -73,6 +73,14 @@ require('lazy').setup({ -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', + -- Toggle term + {'akinsho/toggleterm.nvim', version = "*", config = true}, + + -- Barbar installation + + {'romgrk/barbar.nvim', + dependencies = 'nvim-tree/nvim-web-devicons'}, + -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. { -- LSP Configuration & Plugins @@ -86,6 +94,7 @@ require('lazy').setup({ -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, + -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', }, @@ -96,6 +105,12 @@ require('lazy').setup({ dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, + -- Telescope file browser + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } + }, + -- Useful plugin to show you pending keybinds. { 'folke/which-key.nvim', opts = {} }, { -- Adds git releated signs to the gutter, as well as utilities for managing changes @@ -112,13 +127,7 @@ require('lazy').setup({ }, }, - { -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'onedark' - end, - }, + { "catppuccin/nvim", name = "catppuccin" }, { -- Set lualine as statusline 'nvim-lualine/lualine.nvim', @@ -228,7 +237,257 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true + +-- Set barbar's options +require'bufferline'.setup { + -- Enable/disable animations + animation = false, + + -- Enable/disable auto-hiding the tab bar when there is a single buffer + auto_hide = false, + + -- Enable/disable current/total tabpages indicator (top right corner) + tabpages = true, + + -- Enables/disable clickable tabs + -- - left-click: go to buffer + -- - middle-click: delete buffer + clickable = true, + + -- Excludes buffers from the tabline + exclude_ft = {'javascript'}, + exclude_name = {'package.json'}, + + -- A buffer to this direction will be focused (if it exists) when closing the current buffer. + -- Valid options are 'left' (the default) and 'right' + focus_on_close = 'left', + + -- Hide inactive buffers and file extensions. Other options are `alternate`, `current`, and `visible`. + --hide = {extensions = true, inactive = true}, + + -- Disable highlighting alternate buffers + highlight_alternate = false, + + -- Disable highlighting file icons in inactive buffers + highlight_inactive_file_icons = false, + + -- Enable highlighting visible buffers + highlight_visible = true, + + icons = { + -- Configure the base icons on the bufferline. + buffer_index = false, + buffer_number = false, + button = '', + -- Enables / disables diagnostic symbols + diagnostics = { + [vim.diagnostic.severity.ERROR] = {enabled = true, icon = 'ff'}, + [vim.diagnostic.severity.WARN] = {enabled = false}, + [vim.diagnostic.severity.INFO] = {enabled = false}, + [vim.diagnostic.severity.HINT] = {enabled = true}, + }, + filetype = { + -- Sets the icon's highlight group. + -- If false, will use nvim-web-devicons colors + custom_colors = false, + + -- Requires `nvim-web-devicons` if `true` + enabled = true, + }, + separator = {left = '▎', right = ''}, + + -- Configure the icons on the bufferline when modified or pinned. + -- Supports all the base icon options. + modified = {button = '●'}, + pinned = {button = '車'}, + + -- Configure the icons on the bufferline based on the visibility of a buffer. + -- Supports all the base icon options, plus `modified` and `pinned`. + alternate = {filetype = {enabled = false}}, + current = {buffer_index = true}, + inactive = {button = '×'}, + visible = {modified = {buffer_number = false}}, + }, + + -- If true, new buffers will be inserted at the start/end of the list. + -- Default is to insert after current buffer. + insert_at_end = false, + insert_at_start = false, + + -- Sets the maximum padding width with which to surround each tab + maximum_padding = 1, + + -- Sets the minimum padding width with which to surround each tab + minimum_padding = 1, + + -- Sets the maximum buffer name length. + maximum_length = 30, + + -- If set, the letters for each buffer in buffer-pick mode will be + -- assigned based on their name. Otherwise or in case all letters are + -- already assigned, the behavior is to assign letters in order of + -- usability (see order below) + semantic_letters = true, + + -- New buffer letters are assigned in this order. This order is + -- optimal for the qwerty keyboard layout but might need adjustement + -- for other layouts. + letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP', + + -- Sets the name of unnamed buffers. By default format is "[Buffer X]" + -- where X is the buffer number. But only a static string is accepted here. + no_name_title = nil, +} +require("catppuccin").setup({ + flavour = "mocha", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = false, + show_end_of_buffer = false, -- show the '~' characters after the end of buffers + term_colors = false, + dim_inactive = { + enabled = false, + shade = "dark", + percentage = 0.15, + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + telescope = true, + notify = false, + mini = false, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, +}) + +-- setup must be called before loading +vim.cmd.colorscheme "catppuccin" + -- [[ Basic Keymaps ]] +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } +local keymap = vim.api.nvim_set_keymap + + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Rebind jk to exit insert mode +keymap("i", "jk", "", opts) +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +keymap("n", "tt", ":Neotree", opts) +keymap("n", "", ":ToggleTerm", opts) +keymap("t", "", "exit", term_opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Move text up and down +keymap("v", "", ":m .+1==", opts) +keymap("v", "", ":m .-2==", opts) +keymap("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +keymap("t", "", "h", term_opts) +keymap("t", "", "j", term_opts) +keymap("t", "", "k", term_opts) +keymap("t", "", "l", term_opts) + + +-- Barbar keymaps + +local map = vim.api.nvim_set_keymap + +-- Move to previous/next +map('n', '', 'BufferPrevious', opts) +map('n', '', 'BufferNext', opts) +-- Re-order to previous/next +map('n', '', 'BufferMovePrevious', opts) +map('n', '>', 'BufferMoveNext', opts) +-- Goto buffer in position... +map('n', '', 'BufferGoto 1', opts) +map('n', '', 'BufferGoto 2', opts) +map('n', '', 'BufferGoto 3', opts) +map('n', '', 'BufferGoto 4', opts) +map('n', '', 'BufferGoto 5', opts) +map('n', '', 'BufferGoto 6', opts) +map('n', '', 'BufferGoto 7', opts) +map('n', '', 'BufferGoto 8', opts) +map('n', '', 'BufferGoto 9', opts) +map('n', '', 'BufferLast', opts) +-- Pin/unpin buffer +map('n', '', 'BufferPin', opts) +-- Close buffer +map('n', '', 'BufferClose', opts) +-- Wipeout buffer +-- :BufferWipeout +-- Close commands +-- :BufferCloseAllButCurrent +-- :BufferCloseAllButPinned +-- :BufferCloseAllButCurrentOrPinned +-- :BufferCloseBuffersLeft +-- :BufferCloseBuffersRight +-- Magic buffer-picking mode +map('n', '', 'BufferPick', opts) +-- Sort automatically by... +map('n', 'bb', 'BufferOrderByBufferNumber', opts) +map('n', 'bd', 'BufferOrderByDirectory', opts) +map('n', 'bl', 'BufferOrderByLanguage', opts) +map('n', 'bw', 'BufferOrderByWindowNumber', opts) + + + + -- Keymaps for better default experience -- See `:help vim.keymap.set()` @@ -262,6 +521,46 @@ require('telescope').setup { }, } +-- File browser configuration +-- You don't need to set any of these options. +-- IMPORTANT!: this is only a showcase of how you can set default options! +require("telescope").setup { + extensions = { + file_browser = { + theme = "ivy", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + ["i"] = { + -- your custom insert mode mappings + }, + ["n"] = { + -- your custom normal mode mappings + }, + }, + }, + }, +} +-- To get telescope-file-browser loaded and working with telescope, +-- you need to call load_extension, somewhere after setup function: +require("telescope").load_extension "file_browser" + +-- File browser keymaps +vim.api.nvim_set_keymap( + "n", + "fb", + ":Telescope file_browser", + { noremap = true } +) + +-- open file_browser with the path of the current buffer +vim.api.nvim_set_keymap( + "n", + "fb", + ":Telescope file_browser path=%:p:h select_buffer=true", + { noremap = true } +) + -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua new file mode 100644 index 00000000..55580ad2 --- /dev/null +++ b/lua/custom/plugins/filetree.lua @@ -0,0 +1,15 @@ +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..e91323d1 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,9 @@ -- You can add your own plugins here or in other files in this directory! -- I promise not to create any merge conflicts in this directory :) -- +vim.cmd [[au VimEnter,VimResume * set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50 + \,a:blinkon0-blinkon0-blinkon0-Cursor/lCursor + \,sm:block-blinkon0-blinkon0-blinkon0 +au VimLeave,VimSuspend * set guicursor=a:hor50-blinkon0]] -- See the kickstart.nvim README for more information return {}