Update init.lua

This commit is contained in:
Rui Xuan 2024-07-21 13:04:01 +08:00 committed by GitHub
parent 2df5137e59
commit bdcf55a34b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 73 additions and 28 deletions

101
init.lua
View File

@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
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.opt.relativenumber = true vim.opt.relativenumber = true
-- 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'
@ -209,10 +209,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git' local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
@ -230,7 +227,7 @@ vim.opt.rtp:prepend(lazypath)
require('lazy').setup({ require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
'github/copilot.vim',
-- NOTE: Plugins can also be added by using a table, -- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following -- with the first argument being the link and the following
-- keys can be used to configure plugin behavior/loading/etc. -- keys can be used to configure plugin behavior/loading/etc.
@ -283,15 +280,19 @@ require('lazy').setup({
require('which-key').setup() require('which-key').setup()
-- Document existing key chains -- Document existing key chains
require('which-key').add { require('which-key').register {
{ '<leader>c', group = '[C]ode' }, ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
{ '<leader>d', group = '[D]ocument' }, ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
{ '<leader>r', group = '[R]ename' }, ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
{ '<leader>s', group = '[S]earch' }, ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
{ '<leader>w', group = '[W]orkspace' }, ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
{ '<leader>t', group = '[T]oggle' }, ['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, ['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
} }
-- visual mode
require('which-key').register({
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
end, end,
}, },
@ -564,10 +565,10 @@ require('lazy').setup({
-- - settings (table): Override the default settings passed when initializing the server. -- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = { local servers = {
-- clangd = {}, clangd = {},
-- gopls = {}, -- gopls = {},
-- pyright = {}, ruff = {},
-- rust_analyzer = {}, rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
-- --
-- Some languages (like typescript) have entire language plugins that can be useful: -- Some languages (like typescript) have entire language plugins that can be useful:
@ -651,9 +652,8 @@ require('lazy').setup({
end, end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
json = { 'jq' },
-- Conform can also run multiple formatters sequentially -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use a sub-list to tell conform to run *until* a formatter -- You can use a sub-list to tell conform to run *until* a formatter
-- is found. -- is found.
-- javascript = { { "prettierd", "prettier" } }, -- javascript = { { "prettierd", "prettier" } },
@ -777,15 +777,33 @@ 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`.
'folke/tokyonight.nvim', 'rebelot/kanagawa.nvim',
lazy = false,
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() config = function()
-- Load the colorscheme here. -- Default options:
-- Like many other themes, this one has different styles, and you could load require('kanagawa').setup {
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. compile = false, -- enable compiling the colorscheme
vim.cmd.colorscheme 'tokyonight-night' undercurl = true, -- enable undercurls
commentStyle = { italic = true },
-- You can configure highlights by doing something like: functionStyle = {},
keywordStyle = { italic = true },
statementStyle = { bold = true },
typeStyle = {},
transparent = false, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = { -- add/modify theme and palette colors
palette = {},
theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
},
background = { -- map the value of 'background' option to a theme
dark = 'wave', -- try "dragon" !
light = 'wave',
},
}
-- setup must be called before loading
vim.cmd 'colorscheme kanagawa-wave'
vim.cmd.hi 'Comment gui=none' vim.cmd.hi 'Comment gui=none'
end, end,
}, },
@ -834,7 +852,7 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
opts = { opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'python', 'rust', 'zig' },
-- Autoinstall languages that are not installed -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
highlight = { highlight = {
@ -862,6 +880,33 @@ require('lazy').setup({
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
end, end,
}, },
{
'cameron-wags/rainbow_csv.nvim',
config = true,
ft = {
'csv',
'tsv',
'csv_semicolon',
'csv_whitespace',
'csv_pipe',
'rfc_csv',
'rfc_semicolon',
},
cmd = {
'RainbowDelim',
'RainbowDelimSimple',
'RainbowDelimQuoted',
'RainbowMultiDelim',
},
},
{
'iamcco/markdown-preview.nvim',
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.fn['mkdp#util#install']()
end,
},
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- init.lua. If you want these files, they are in the repository, so you can just download them and -- init.lua. If you want these files, they are in the repository, so you can just download them and