Revert "upload config"

This reverts commit 9a78f2e38c.
This commit is contained in:
hoangvietdo 2024-04-08 11:35:02 +09:00
parent 9a78f2e38c
commit ecd1f2ae16
1 changed files with 27 additions and 165 deletions

192
init.lua
View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed -- Set to true if you have a Nerd Font installed
vim.g.have_nerd_font = true vim.g.have_nerd_font = false
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.opt` -- See `:help vim.opt`
@ -102,9 +102,7 @@ vim.g.have_nerd_font = true
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- Experiment for yourself to see if you like it!
vim.cmd 'autocmd InsertEnter * :set relativenumber' -- vim.opt.relativenumber = true
vim.cmd 'autocmd InsertLeave * :set norelativenumber'
vim.opt.cmdheight = 1
-- Enable mouse mode, can be useful for resizing splits for example! -- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
@ -239,6 +237,9 @@ require('lazy').setup({
-- This is equivalent to: -- This is equivalent to:
-- require('Comment').setup({}) -- require('Comment').setup({})
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
-- Here is a more advanced example where we pass configuration -- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
-- require('gitsigns').setup({ ... }) -- require('gitsigns').setup({ ... })
@ -373,7 +374,7 @@ require('lazy').setup({
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>fh', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme -- 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. -- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys -- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>fg', function() vim.keymap.set('n', '<leader>s/', function()
builtin.live_grep { builtin.live_grep {
grep_open_files = true, grep_open_files = true,
prompt_title = 'Live Grep in Open Files', prompt_title = 'Live Grep in Open Files',
@ -395,7 +396,7 @@ require('lazy').setup({
end, { desc = '[S]earch [/] in Open Files' }) end, { desc = '[S]earch [/] in Open Files' })
-- Shortcut for searching your Neovim configuration files -- Shortcut for searching your Neovim configuration files
vim.keymap.set('n', '<leader>ff', function() vim.keymap.set('n', '<leader>sn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' } builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' }) end, { desc = '[S]earch [N]eovim files' })
end, end,
@ -701,7 +702,7 @@ require('lazy').setup({
-- Accept ([y]es) the completion. -- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it. -- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet. -- This will expand snippets if the LSP sent a snippet.
['<TAB>'] = cmp.mapping.confirm { select = true }, ['<C-y>'] = cmp.mapping.confirm { select = true },
-- Manually trigger a completion from nvim-cmp. -- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display -- 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. -- 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`. -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'catppuccin/nvim', 'folke/tokyonight.nvim',
name = 'catppuccin',
priority = 1000, -- Make sure to load this before all the other start plugins. priority = 1000, -- Make sure to load this before all the other start plugins.
init = function() init = function()
-- Load the colorscheme here. -- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load -- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. -- 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: -- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none' vim.cmd.hi 'Comment gui=none'
end, end,
}, },
{
'numToStr/Comment.nvim',
opts = {
toggler = {
-- Line-comment toggle keymap
line = '<leader>a',
-- Block-comment toggle keymap
-- block = "<leader>a",
},
opleader = {
---Line-comment keymap
line = '<leader>a',
-- -Block-comment keymap
-- block = "<leader>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 = {
{ '<leader>bp', '<Cmd>BufferLineTogglePin<CR>', desc = 'Toggle Pin' },
{ '<leader>bP', '<Cmd>BufferLineGroupClose ungrouped<CR>', desc = 'Delete Non-Pinned Buffers' },
{ '<leader>bo', '<Cmd>BufferLineCloseOthers<CR>', desc = 'Delete Other Buffers' },
{ '<leader>br', '<Cmd>BufferLineCloseRight<CR>', desc = 'Delete Buffers to the Right' },
{ '<leader>bl', '<Cmd>BufferLineCloseLeft<CR>', desc = 'Delete Buffers to the Left' },
{ '<S-h>', '<cmd>BufferLineCyclePrev<cr>', desc = 'Prev Buffer' },
{ '<S-l>', '<cmd>BufferLineCycleNext<cr>', desc = 'Next Buffer' },
{ '[b', '<cmd>BufferLineCyclePrev<cr>', desc = 'Prev Buffer' },
{ ']b', '<cmd>BufferLineCycleNext<cr>', 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 -- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, { '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 [)] ['] -- - sr)' - [S]urround [R]eplace [)] [']
require('mini.surround').setup() 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! -- ... and there is more!
-- Check out: https://github.com/echasnovski/mini.nvim -- Check out: https://github.com/echasnovski/mini.nvim
end, end,
@ -940,7 +802,7 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
opts = { 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 -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
highlight = { highlight = {