From bdcf55a34b64a4d08ee980dc73a8cfe3b25b4240 Mon Sep 17 00:00:00 2001 From: Rui Xuan Date: Sun, 21 Jul 2024 13:04:01 +0800 Subject: [PATCH] Update init.lua --- init.lua | 101 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 28 deletions(-) diff --git a/init.lua b/init.lua index 624e23d8..d9443860 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false 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.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -209,10 +209,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - local out = 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 + vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) @@ -230,7 +227,7 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - + 'github/copilot.vim', -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. @@ -283,15 +280,19 @@ require('lazy').setup({ require('which-key').setup() -- Document existing key chains - require('which-key').add { - { 'c', group = '[C]ode' }, - { 'd', group = '[D]ocument' }, - { 'r', group = '[R]ename' }, - { 's', group = '[S]earch' }, - { 'w', group = '[W]orkspace' }, - { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, } + -- visual mode + require('which-key').register({ + ['h'] = { 'Git [H]unk' }, + }, { mode = 'v' }) end, }, @@ -564,10 +565,10 @@ require('lazy').setup({ -- - 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/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + ruff = {}, + rust_analyzer = {}, -- ... 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: @@ -651,9 +652,8 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + json = { 'jq' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. -- javascript = { { "prettierd", "prettier" } }, @@ -777,15 +777,33 @@ 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`. - 'folke/tokyonight.nvim', + 'rebelot/kanagawa.nvim', + lazy = false, 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 'tokyonight-night' - - -- You can configure highlights by doing something like: + config = function() + -- Default options: + require('kanagawa').setup { + compile = false, -- enable compiling the colorscheme + undercurl = true, -- enable undercurls + commentStyle = { italic = true }, + 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' end, }, @@ -834,7 +852,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', 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 auto_install = true, highlight = { @@ -862,6 +880,33 @@ require('lazy').setup({ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects 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 -- init.lua. If you want these files, they are in the repository, so you can just download them and