diff --git a/init.lua b/init.lua index 6308a7b2..496f45b8 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 -vim.g.have_nerd_font = true +vim.g.have_nerd_font = false -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,9 +102,7 @@ vim.g.have_nerd_font = true vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! -vim.cmd 'autocmd InsertEnter * :set relativenumber' -vim.cmd 'autocmd InsertLeave * :set norelativenumber' -vim.opt.cmdheight = 1 +-- vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -239,6 +237,9 @@ require('lazy').setup({ -- This is equivalent to: -- require('Comment').setup({}) + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- require('gitsigns').setup({ ... }) @@ -373,7 +374,7 @@ require('lazy').setup({ vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 'fh', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme @@ -387,7 +388,7 @@ require('lazy').setup({ -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 'fg', function() + vim.keymap.set('n', 's/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', @@ -395,7 +396,7 @@ require('lazy').setup({ end, { desc = '[S]earch [/] in Open Files' }) -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'ff', function() + vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) end, @@ -701,7 +702,7 @@ require('lazy').setup({ -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -744,173 +745,19 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'catppuccin/nvim', - name = 'catppuccin', + 'folke/tokyonight.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'catppuccin-mocha' + vim.cmd.colorscheme 'tokyonight-night' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' end, }, - { - 'numToStr/Comment.nvim', - opts = { - toggler = { - -- Line-comment toggle keymap - line = 'a', - -- Block-comment toggle keymap - -- block = "a", - }, - opleader = { - ---Line-comment keymap - line = 'a', - -- -Block-comment keymap - -- block = "a", - }, - }, - lazy = false, - }, - - { - 'nvim-lualine/lualine.nvim', - event = 'VeryLazy', - opts = function() - return { - options = { - theme = 'auto', - section_separators = { left = '', right = '' }, - component_separators = { left = '', right = '' }, - globalstatus = true, - -- disabled_filetypes = { statusline = { 'dashboard', 'alpha', 'TelescopePrompt' } }, - disabled_filestypes = {}, - }, - sections = { - lualine_a = { - { - 'mode', - icons_enabled = true, - -- icon = "/ᐠﹷ ‸ ﹷ ᐟ\\ノ", - icon = 'ฅ^•ﻌ•^ฅ', - }, - }, - lualine_y = { - { 'progress', padding = { left = 1, right = 0 }, separator = ' ' }, - { 'location', padding = { left = 0, right = 1 } }, - { - function() - -- return tostring(vim.fn.wordcount().words) .. " Words" .. ", " .. "%L" .. " Lines" - return tostring(vim.fn.wordcount().words) .. '-' .. '%L' - end, - }, - { 'searchcount', maxcount = 999, timeout = 500 }, - }, - lualine_z = { - -- "os.date('%a (%j/365)')", - function() - return ' ' .. os.date '%b %d(%a), %Y' - end, - -- "os.date('%b %d, %Y')", - function() - return ' ' .. os.date '%T %Z' - end, - }, - }, - } - end, - }, - - { - 'nvimdev/dashboard-nvim', - event = 'VimEnter', - config = function() - require('dashboard').setup { - -- config - theme = 'doom', - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = vim.split('Viet Do', '\n'), - center = { - { action = 'Telescope find_files', desc = ' Find File', icon = ' ', key = 'f' }, - { action = 'ene | startinsert', desc = ' New File', icon = ' ', key = 'n' }, - { action = 'Telescope oldfiles', desc = ' Recent Files', icon = ' ', key = 'r' }, - { action = 'Telescope live_grep', desc = ' Find Text', icon = ' ', key = 'g' }, - { action = [[lua LazyVim.telescope.config_files()()]], desc = ' Config', icon = ' ', key = 'c' }, - { action = 'lua require("persistence").load()', desc = ' Restore Session', icon = ' ', key = 's' }, - { action = 'LazyExtras', desc = ' Lazy Extras', icon = ' ', key = 'x' }, - { action = 'Lazy', desc = ' Lazy', icon = '󰒲 ', key = 'l' }, - { action = 'qa', desc = ' Quit', icon = ' ', key = 'q' }, - }, - footer = function() - local stats = require('lazy').stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { '⚡ Neovim loaded ' .. stats.loaded .. '/' .. stats.count .. ' plugins in ' .. ms .. 'ms' } - end, - }, - } - end, - dependencies = { { 'nvim-tree/nvim-web-devicons' } }, - }, - - { - 'akinsho/bufferline.nvim', - event = 'VeryLazy', - keys = { - { 'bp', 'BufferLineTogglePin', desc = 'Toggle Pin' }, - { 'bP', 'BufferLineGroupClose ungrouped', desc = 'Delete Non-Pinned Buffers' }, - { 'bo', 'BufferLineCloseOthers', desc = 'Delete Other Buffers' }, - { 'br', 'BufferLineCloseRight', desc = 'Delete Buffers to the Right' }, - { 'bl', 'BufferLineCloseLeft', desc = 'Delete Buffers to the Left' }, - { '', 'BufferLineCyclePrev', desc = 'Prev Buffer' }, - { '', 'BufferLineCycleNext', desc = 'Next Buffer' }, - { '[b', 'BufferLineCyclePrev', desc = 'Prev Buffer' }, - { ']b', 'BufferLineCycleNext', desc = 'Next Buffer' }, - }, - opts = { - options = { - -- stylua: ignore - close_command = function(n) require("mini.bufremove").delete(n, false) end, - -- stylua: ignore - right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end, - diagnostics = 'nvim_lsp', - always_show_bufferline = false, - diagnostics_indicator = function(_, _, diag) - local icons = require('lazyvim.config').icons.diagnostics - local ret = (diag.error and icons.Error .. diag.error .. ' ' or '') .. (diag.warning and icons.Warn .. diag.warning or '') - return vim.trim(ret) - end, - offsets = { - { - filetype = 'neo-tree', - text = 'Neo-tree', - highlight = 'Directory', - text_align = 'left', - }, - }, - }, - }, - config = function(_, opts) - require('bufferline').setup(opts) - -- Fix bufferline when restoring a session - vim.api.nvim_create_autocmd('BufAdd', { - callback = function() - vim.schedule(function() - pcall(nvim_bufferline) - end) - end, - }) - end, - }, - -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, @@ -932,6 +779,21 @@ require('lazy').setup({ -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').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' + -- set use_icons to true if you have a 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 + -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim end, @@ -940,7 +802,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'cpp', 'python', 'cmake', 'xml', 'yaml', 'json', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = {