From ad0a848a78ae2bb081ad2cc9a3a194ae61cb732f Mon Sep 17 00:00:00 2001 From: dayatz Date: Fri, 3 May 2024 11:09:40 +0800 Subject: [PATCH] add configs --- init.lua | 102 +++++++++++++++++++-------- lua/custom/plugins/leap.lua | 6 ++ lua/custom/plugins/nvim-surround.lua | 20 ++++++ 3 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 lua/custom/plugins/leap.lua create mode 100644 lua/custom/plugins/nvim-surround.lua diff --git a/init.lua b/init.lua index 457ad214..8a0c9bea 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' @@ -185,10 +185,18 @@ vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' } -- Use CTRL+ to switch between windows -- -- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- split windows +vim.keymap.set("n", "sv", "v") -- split veritcally +vim.keymap.set("n", "sh", "s") -- split horizontally +vim.keymap.set("n", "se", "=") -- equal windows +vim.keymap.set("n", "sx", ":close") -- close + +vim.keymap.set('i', 'jk', '') -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -353,11 +361,15 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, + defaults = { + mappings = { + i = { + [''] = require('telescope.actions').move_selection_previous, -- move to prev result + [''] = require('telescope.actions').move_selection_next, -- move to next result + [''] = require('telescope.actions').send_selected_to_qflist + require('telescope.actions').open_qflist, -- send selected to quickfixlist + }, + }, + }, -- pickers = {} extensions = { ['ui-select'] = { @@ -640,18 +652,23 @@ require('lazy').setup({ }, opts = { notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } - end, + -- format_on_save = function(bufnr) + -- -- Disable "format_on_save lsp_fallback" for languages that don't + -- -- have a well standardized coding style. You can add additional + -- -- languages here or re-enable it for the disabled ones. + -- local disable_filetypes = { c = true, cpp = true } + -- return { + -- timeout_ms = 500, + -- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], + -- } + -- end, formatters_by_ft = { lua = { 'stylua' }, + javascript = { { 'prettierd', 'prettier' } }, + javascriptreact = { { 'prettierd', 'prettier' } }, + typescript = { { 'prettierd', 'prettier' } }, + typescriptreact = { { 'prettierd', 'prettier' } }, + python = { 'ruff_format', 'ruff_fix' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -718,9 +735,9 @@ require('lazy').setup({ -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_prev_item(), -- Scroll the documentation window [b]ack / [f]orward [''] = cmp.mapping.scroll_docs(-4), @@ -729,7 +746,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 }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines @@ -810,7 +827,12 @@ require('lazy').setup({ -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() + -- require('mini.surround').setup() + require('mini.indentscope').setup { + draw = { + animation = require('mini.indentscope').gen_animation.none(), + }, + } -- Simple and easy statusline. -- You could remove this setup call if you don't like it, @@ -835,7 +857,28 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { + 'json', + 'javascript', + 'typescript', + 'tsx', + 'yaml', + 'html', + 'css', + 'markdown', + 'markdown_inline', + 'svelte', + 'graphql', + 'bash', + 'lua', + 'vim', + 'dockerfile', + 'gitignore', + 'python', + 'toml', + 'prisma', + 'vue', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -864,6 +907,7 @@ require('lazy').setup({ 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 -- place them in the correct locations. @@ -876,16 +920,16 @@ require('lazy').setup({ -- 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.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/leap.lua b/lua/custom/plugins/leap.lua new file mode 100644 index 00000000..f406d4c5 --- /dev/null +++ b/lua/custom/plugins/leap.lua @@ -0,0 +1,6 @@ +return { + 'ggandor/leap.nvim', + config = function() + require('leap').create_default_mappings() + end +} diff --git a/lua/custom/plugins/nvim-surround.lua b/lua/custom/plugins/nvim-surround.lua new file mode 100644 index 00000000..64584bbf --- /dev/null +++ b/lua/custom/plugins/nvim-surround.lua @@ -0,0 +1,20 @@ +return { + 'kylechui/nvim-surround', + config = function() + require('nvim-surround').setup { + keymaps = { + insert = 's', + insert_line = 'S', + normal = 'ys', + normal_cur = 'yss', + normal_line = 'yS', + normal_cur_line = 'ySS', + visual = 'vs', + visual_line = 'vS', + delete = 'ds', + change = 'cs', + change_line = 'cS', + }, + } + end, +}