add configs

This commit is contained in:
dayatz 2024-05-03 11:09:40 +08:00
parent 6f6f38a6b5
commit ad0a848a78
3 changed files with 99 additions and 29 deletions

102
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'
@ -185,10 +185,18 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
-- Use CTRL+<hjkl> to switch between windows -- Use CTRL+<hjkl> to switch between windows
-- --
-- See `:help wincmd` for a list of all window commands -- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' }) -- vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) -- vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) -- vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) -- vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- split windows
vim.keymap.set("n", "<leader>sv", "<C-w>v") -- split veritcally
vim.keymap.set("n", "<leader>sh", "<C-w>s") -- split horizontally
vim.keymap.set("n", "<leader>se", "<C-w>=") -- equal windows
vim.keymap.set("n", "<leader>sx", ":close<CR>") -- close
vim.keymap.set('i', 'jk', '<ESC>')
-- [[ Basic Autocommands ]] -- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands` -- See `:help lua-guide-autocommands`
@ -353,11 +361,15 @@ require('lazy').setup({
-- You can put your default mappings / updates / etc. in here -- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()` -- All the info you're looking for is in `:help telescope.setup()`
-- --
-- defaults = { defaults = {
-- mappings = { mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' }, i = {
-- }, ['<C-k>'] = require('telescope.actions').move_selection_previous, -- move to prev result
-- }, ['<C-j>'] = require('telescope.actions').move_selection_next, -- move to next result
['<C-q>'] = require('telescope.actions').send_selected_to_qflist + require('telescope.actions').open_qflist, -- send selected to quickfixlist
},
},
},
-- pickers = {} -- pickers = {}
extensions = { extensions = {
['ui-select'] = { ['ui-select'] = {
@ -640,18 +652,23 @@ require('lazy').setup({
}, },
opts = { opts = {
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) -- format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't -- -- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional -- -- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones. -- -- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true } -- local disable_filetypes = { c = true, cpp = true }
return { -- return {
timeout_ms = 500, -- timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], -- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
} -- }
end, -- end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, 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 -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" }, -- python = { "isort", "black" },
-- --
@ -718,9 +735,9 @@ require('lazy').setup({
-- No, but seriously. Please read `:help ins-completion`, it is really good! -- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item -- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(), ['<C-j>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item -- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(), ['<C-k>'] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward -- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
@ -729,7 +746,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.
['<C-y>'] = cmp.mapping.confirm { select = true }, ['<CR>'] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps, -- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines -- you can uncomment the following lines
@ -810,7 +827,12 @@ require('lazy').setup({
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes -- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] ['] -- - 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. -- Simple and easy statusline.
-- You could remove this setup call if you don't like it, -- You could remove this setup call if you don't like it,
@ -835,7 +857,28 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
opts = { 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 -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
highlight = { highlight = {
@ -864,6 +907,7 @@ require('lazy').setup({
end, 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
-- place them in the correct locations. -- place them in the correct locations.
@ -876,16 +920,16 @@ require('lazy').setup({
-- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs', require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps 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` -- 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. -- 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. -- 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` -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' }, { import = 'custom.plugins' },
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

View File

@ -0,0 +1,6 @@
return {
'ggandor/leap.nvim',
config = function()
require('leap').create_default_mappings()
end
}

View File

@ -0,0 +1,20 @@
return {
'kylechui/nvim-surround',
config = function()
require('nvim-surround').setup {
keymaps = {
insert = '<C-g>s',
insert_line = '<C-g>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,
}