From 84ea367081d8a88362357eb3b12ce6321c3dd4bc Mon Sep 17 00:00:00 2001 From: dover_shen Date: Mon, 19 Aug 2024 22:33:37 +0800 Subject: [PATCH] setup-complete-2024-08-19 --- init.lua | 172 +++++++++++--------------- lua/custom/plugins/autotag.lua | 25 ++++ lua/custom/plugins/barbecue.lua | 12 ++ lua/custom/plugins/harpoon.lua | 42 +++++++ lua/custom/plugins/lualine.lua | 71 +++++++++++ lua/kickstart/plugins/indent_line.lua | 4 +- 6 files changed, 223 insertions(+), 103 deletions(-) create mode 100644 lua/custom/plugins/autotag.lua create mode 100644 lua/custom/plugins/barbecue.lua create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/lualine.lua diff --git a/init.lua b/init.lua index 220d3045..df6e0279 100644 --- a/init.lua +++ b/init.lua @@ -1,89 +1,3 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -91,7 +5,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` @@ -102,7 +16,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' @@ -145,8 +59,8 @@ vim.opt.splitbelow = true -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.list = false +vim.opt.listchars = { trail = '·', nbsp = '␣' } -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' @@ -166,6 +80,8 @@ vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- NOTE: Custom +vim.keymap.set('n', 'fd', vim.diagnostic.open_float, { desc = 'Open diagnostic flow' }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which @@ -288,6 +204,15 @@ require('lazy').setup({ { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, } end, + keys = { + { + '?', + function() + require('which-key').show { global = true } + end, + desc = 'Global Keymaps', + }, + }, }, -- NOTE: Plugins can specify dependencies. @@ -343,6 +268,7 @@ require('lazy').setup({ -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` + local actions = require 'telescope.actions' require('telescope').setup { -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` @@ -353,6 +279,17 @@ require('lazy').setup({ -- }, -- }, -- pickers = {} + defaults = { + path_display = { 'smart' }, + mappings = { + i = { + [''] = 'to_fuzzy_refine', + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -376,6 +313,7 @@ require('lazy').setup({ vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'gs', builtin.git_status, { desc = 'git status' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() @@ -579,8 +517,13 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, + tsserver = {}, -- + prettierd = {}, + prettier = {}, + eslint = {}, + html = {}, + cssls = {}, lua_ls = { -- cmd = {...}, @@ -657,6 +600,14 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + typescript = { 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + css = { 'prettierd', 'prettier', stop_after_first = true }, + html = { 'prettierd', 'prettier', stop_after_first = true }, + json = { 'prettierd', 'prettier', stop_after_first = true }, + markdown = { 'prettierd', 'prettier', stop_after_first = true }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -737,9 +688,9 @@ require('lazy').setup({ -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -787,20 +738,37 @@ 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', 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' + vim.cmd.colorscheme 'kanagawa' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' end, + config = function() + require('kanagawa').setup { + background = { + dark = 'dragon', + }, + } + end, }, -- Highlight todo, notes, etc in comments + -- NOTE: 註釋 + -- TODO: 待處理 + -- FIXME: 已知錯誤,需修正、改進 + -- FIXIT: 需要修正、改進 + -- ISSUE: 發現的問題,或待調查 + -- BUG: 確定存在錯誤,需修復 + -- HACK: 臨時、不完美的解決方案 + -- WARNING: 可能引發問題的代碼,需小心處理 + -- TEST: 測試相關註解 + -- PERF: 性能相關註解 { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, { -- Collection of various small independent plugins/modules @@ -880,19 +848,19 @@ 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.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 + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- 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/plugins/autotag.lua b/lua/custom/plugins/autotag.lua new file mode 100644 index 00000000..a15806ed --- /dev/null +++ b/lua/custom/plugins/autotag.lua @@ -0,0 +1,25 @@ +return { + 'windwp/nvim-ts-autotag', + config = function() + require('nvim-ts-autotag').setup { + opts = { + -- Defaults + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing a', function() + harpoon:list():add() + end) + vim.keymap.set('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + vim.keymap.set('n', '1', function() + harpoon:list():select(1) + end) + vim.keymap.set('n', '2', function() + harpoon:list():select(2) + end) + vim.keymap.set('n', '3', function() + harpoon:list():select(3) + end) + vim.keymap.set('n', '4', function() + harpoon:list():select(4) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(3) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(4) + end) + end, +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..7a85fe15 --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,71 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + local lualine = require 'lualine' + local lazy_status = require 'lazy.status' -- to configure lazy pending updates count + + local colors = { + blue = '#65D1FF', + green = '#3EFFDC', + violet = '#FF61EF', + yellow = '#FFDA7B', + red = '#FF4A4A', + fg = '#c3ccdc', + bg = '#112638', + inactive_bg = '#2c3043', + } + + local my_lualine_theme = { + normal = { + a = { bg = colors.blue, fg = colors.bg, gui = 'bold' }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + insert = { + a = { bg = colors.green, fg = colors.bg, gui = 'bold' }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + visual = { + a = { bg = colors.violet, fg = colors.bg, gui = 'bold' }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + command = { + a = { bg = colors.yellow, fg = colors.bg, gui = 'bold' }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + replace = { + a = { bg = colors.red, fg = colors.bg, gui = 'bold' }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + inactive = { + a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = 'bold' }, + b = { bg = colors.inactive_bg, fg = colors.semilightgray }, + c = { bg = colors.inactive_bg, fg = colors.semilightgray }, + }, + } + + -- configure lualine with modified theme + lualine.setup { + options = { + theme = my_lualine_theme, + }, + sections = { + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = '#ff9e64' }, + }, + { 'encoding' }, + { 'fileformat' }, + { 'filetype' }, + }, + }, + } + end, +} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua index ed7f2693..ba1489d0 100644 --- a/lua/kickstart/plugins/indent_line.lua +++ b/lua/kickstart/plugins/indent_line.lua @@ -4,6 +4,8 @@ return { -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help ibl` main = 'ibl', - opts = {}, + opts = { + indent = { char = '▏' }, + }, }, }