From 94fb9a225533dd2f7469735a8caf169356c3673c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Mu=C3=B1oz=20Paredes?= Date: Fri, 19 Apr 2024 15:20:25 +0200 Subject: [PATCH] Init config --- init.lua | 35 +++++++++--------- lua/custom/init.lua | 56 +++++++++++++++++++++++++++++ lua/custom/plugins/autosave.lua | 9 +++++ lua/custom/plugins/barbar.lua | 19 ++++++++++ lua/custom/plugins/lualine.lua | 63 +++++++++++++++++++++++++++++++++ lua/custom/plugins/neo-tree.lua | 17 +++++++++ 6 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 lua/custom/init.lua create mode 100644 lua/custom/plugins/autosave.lua create mode 100644 lua/custom/plugins/barbar.lua create mode 100644 lua/custom/plugins/lualine.lua create mode 100644 lua/custom/plugins/neo-tree.lua diff --git a/init.lua b/init.lua index a182828e..efe23f02 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -204,6 +204,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +require 'custom.init' -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -671,12 +672,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -798,17 +799,17 @@ require('lazy').setup({ -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin - local statusline = require 'mini.statusline' + -- local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } + -- statusline.setup { use_icons = vim.g.have_nerd_font } -- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for -- cursor location to LINE:COLUMN ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end + -- statusline.section_location = function() + -- return '%2l:%-2v' + -- end -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim @@ -856,10 +857,10 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps @@ -868,7 +869,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 00000000..10bb9e97 --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,56 @@ +vim.opt.relativenumber = true + +vim.keymap.set('n', 'n', ':Neotree', { noremap = true, silent = true, desc = 'Open [N]eotree Explorer' }) + +vim.keymap.set('n', '', function() + vim.lsp.buf.format() + vim.cmd.w() +end, { desc = '[S]ave file' }) + +vim.keymap.set('i', '', function() + vim.lsp.buf.format() + vim.cmd.w() +end, { desc = '[S]ave file' }) + +-- mappings barbar + +local map = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } + +-- 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', 'bn', 'BufferOrderByName', opts) +map('n', 'bd', 'BufferOrderByDirectory', opts) +map('n', 'bl', 'BufferOrderByLanguage', opts) +map('n', 'bw', 'BufferOrderByWindowNumber', opts) diff --git a/lua/custom/plugins/autosave.lua b/lua/custom/plugins/autosave.lua new file mode 100644 index 00000000..594109ad --- /dev/null +++ b/lua/custom/plugins/autosave.lua @@ -0,0 +1,9 @@ +return { + 'okuuva/auto-save.nvim', + cmd = 'ASToggle', -- optional for lazy loading on command + event = { 'InsertLeave', 'TextChanged' }, -- optional for lazy loading on trigger events + opts = { + -- your config goes here + -- or just leave it empty :) + }, +} diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua new file mode 100644 index 00000000..8ed38c8a --- /dev/null +++ b/lua/custom/plugins/barbar.lua @@ -0,0 +1,19 @@ +return { + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status + 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons + }, + init = function() + vim.g.barbar_auto_setup = false + end, + opts = { + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + -- animation = true, + -- insert_at_start = true, + -- …etc. + }, + version = '^1.0.0', -- optional: only update when a new 1.x version is released + }, +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..0a555bca --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,63 @@ +local colors = { + blue = '#80a0ff', + cyan = '#79dac8', + black = '#080808', + white = '#c6c6c6', + red = '#ff5189', + violet = '#d183e8', + grey = '#303030', +} + +local bubbles_theme = { + normal = { + a = { fg = colors.black, bg = colors.violet }, + b = { fg = colors.white, bg = colors.grey }, + c = { fg = colors.white }, + }, + + insert = { a = { fg = colors.black, bg = colors.blue } }, + visual = { a = { fg = colors.black, bg = colors.cyan } }, + replace = { a = { fg = colors.black, bg = colors.red } }, + + inactive = { + a = { fg = colors.white, bg = colors.black }, + b = { fg = colors.white, bg = colors.black }, + c = { fg = colors.white }, + }, +} + +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup { + options = { + theme = bubbles_theme, + component_separators = '', + section_separators = { left = '', right = '' }, + }, + sections = { + lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, + lualine_b = { 'filename', 'branch' }, + lualine_c = { + '%=', --[[ add your center compoentnts here in place of this comment ]] + }, + lualine_x = {}, + lualine_y = { 'filetype', 'progress' }, + lualine_z = { + { 'location', separator = { right = '' }, left_padding = 2 }, + }, + }, + inactive_sections = { + lualine_a = { 'filename' }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { 'location' }, + }, + tabline = {}, + extensions = {}, + } + end, +} diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua new file mode 100644 index 00000000..b7a9f07c --- /dev/null +++ b/lua/custom/plugins/neo-tree.lua @@ -0,0 +1,17 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, + config = function() + require('neo-tree').setup { + window = { + position = 'float', + }, + } + end, +}