add basic functionality
This commit is contained in:
parent
1860184830
commit
434ee099bb
196
init.lua
196
init.lua
|
|
@ -160,9 +160,66 @@ vim.opt.scrolloff = 10
|
|||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
||||
-- Clear highlights on search when pressing <Esc> in normal mode
|
||||
-- See `:help hlsearch`
|
||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
-- MY KEYMAPS BEGIN
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
function! s:ZoomToggle() abort
|
||||
if exists('t:zoomed') && t:zoomed
|
||||
execute t:zoom_winrestcmd
|
||||
let t:zoomed = 0
|
||||
else
|
||||
let t:zoom_winrestcmd = winrestcmd()
|
||||
resize
|
||||
vertical resize
|
||||
let t:zoomed = 1
|
||||
endif
|
||||
endfunction
|
||||
command! ZoomToggle call s:ZoomToggle()
|
||||
]],
|
||||
false
|
||||
)
|
||||
|
||||
vim.cmd [[
|
||||
set listchars=eol:¬
|
||||
" hi NonText guibg=#eee
|
||||
nnoremap <silent><expr> ,h (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
|
||||
]]
|
||||
|
||||
vim.keymap.set('n', ';', ':', { noremap = true, desc = 'Command mode' })
|
||||
vim.keymap.set('n', "'", '`', { noremap = true, desc = 'Mark character' })
|
||||
vim.keymap.set('n', '`', "'", { noremap = true, desc = 'Mark line' })
|
||||
-- vim.keymap.set("n", "œ", "<cmd>bdelete<CR>", { silent = true, desc = "Buffer Delete" })
|
||||
vim.keymap.set('n', '<C-z>', '<cmd>ZoomToggle<CR>', { noremap = true, desc = 'Zoom Toggle' })
|
||||
|
||||
vim.keymap.set('i', 'df', '<ESC>', { noremap = true, desc = 'ESC' })
|
||||
vim.keymap.set('n', '<CR>', 'o<ESC>', { noremap = true, desc = 'ESC' })
|
||||
|
||||
vim.keymap.set('n', 'L', '<cmd>bn<CR>', { noremap = true, desc = 'buffer next' })
|
||||
vim.keymap.set('n', 'H', '<cmd>bp<CR>', { noremap = true, desc = 'buffer previous' })
|
||||
|
||||
vim.keymap.set('n', ',n', '<cmd>Neotree toggle<CR>', { noremap = true, desc = 'Tree Toggle' })
|
||||
vim.keymap.set('n', ',N', '<cmd>Neotree reveal left<CR>', { noremap = true, desc = 'Follow File Toggle' })
|
||||
|
||||
vim.keymap.set('n', '<leader>w', '<cmd>:w<CR>', { noremap = true, desc = 'Save file' })
|
||||
|
||||
vim.g.diagnostics_active = false
|
||||
function _G.toggle_diagnostics()
|
||||
if vim.g.diagnostics_active then
|
||||
vim.g.diagnostics_active = false
|
||||
vim.diagnostic.config { virtual_text = false }
|
||||
else
|
||||
vim.g.diagnostics_active = true
|
||||
vim.diagnostic.config { virtual_text = true }
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>uv', ':call v:lua.toggle_diagnostics()<CR>', { noremap = true, silent = true, desc = 'Toggle diagnostic text' })
|
||||
|
||||
-- NOTES
|
||||
-- :g/^$/d delete empty lines
|
||||
-- :v/\w\+/d (skip lines with one or more words) delete empty lines
|
||||
-- !column -t column format
|
||||
-- MY KEYMAPS END
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
|
|
@ -275,7 +332,9 @@ require('lazy').setup({
|
|||
'folke/which-key.nvim',
|
||||
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
||||
config = function() -- This is the function that runs, AFTER loading
|
||||
require('which-key').setup()
|
||||
require('which-key').setup { triggers = {
|
||||
{ '<leader>', mode = { 'n', 'v' } },
|
||||
} }
|
||||
|
||||
-- Document existing key chains
|
||||
require('which-key').add {
|
||||
|
|
@ -343,6 +402,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 +413,34 @@ require('lazy').setup({
|
|||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
require('telescope').setup {
|
||||
pickers = {
|
||||
find_files = {
|
||||
follow = true,
|
||||
cache_picker = false,
|
||||
},
|
||||
buffers = {
|
||||
cache_picker = false,
|
||||
},
|
||||
},
|
||||
defaults = {
|
||||
cache_picker = {
|
||||
num_pickers = 8,
|
||||
},
|
||||
mappings = {
|
||||
i = {
|
||||
['<esc>'] = actions.close,
|
||||
},
|
||||
},
|
||||
layout_strategy = 'horizontal',
|
||||
layout_config = {
|
||||
horizontal = {
|
||||
prompt_position = 'top',
|
||||
},
|
||||
},
|
||||
sorting_strategy = 'ascending',
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
|
|
@ -373,13 +461,15 @@ require('lazy').setup({
|
|||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<C-p>', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<C-b>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<C-n>', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
-- You can pass additional configuration po Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
|
|
@ -497,7 +587,7 @@ require('lazy').setup({
|
|||
|
||||
-- Fuzzy find all the symbols in your current workspace.
|
||||
-- Similar to document symbols, except searches over your entire project.
|
||||
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
map('<leader>sW', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- Rename the variable under your cursor.
|
||||
-- Most Language Servers support renaming across files, etc.
|
||||
|
|
@ -540,6 +630,16 @@ require('lazy').setup({
|
|||
})
|
||||
end
|
||||
|
||||
-- custom auto format
|
||||
if client then
|
||||
client.server_capabilities.documentFormattingProvider = true
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- The following code creates a keymap to toggle inlay hints in your
|
||||
-- code, if the language server you are using supports them
|
||||
--
|
||||
|
|
@ -649,7 +749,7 @@ require('lazy').setup({
|
|||
-- 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 }
|
||||
local disable_filetypes = { c = true, cpp = true, javascript = true }
|
||||
return {
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
|
||||
|
|
@ -661,7 +761,7 @@ require('lazy').setup({
|
|||
-- python = { "isort", "black" },
|
||||
--
|
||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
-- javascript = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -686,12 +786,12 @@ require('lazy').setup({
|
|||
-- `friendly-snippets` contains a variety of premade snippets.
|
||||
-- See the README about individual language/framework/plugin snippets:
|
||||
-- https://github.com/rafamadriz/friendly-snippets
|
||||
-- {
|
||||
-- 'rafamadriz/friendly-snippets',
|
||||
-- config = function()
|
||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
'rafamadriz/friendly-snippets',
|
||||
config = function()
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
|
|
@ -714,7 +814,10 @@ require('lazy').setup({
|
|||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
completion = { completeopt = 'menu,menuone,noinsert' },
|
||||
preselect = cmp.PreselectMode.None,
|
||||
completion = {
|
||||
completeopt = 'menu,menuone,noinsert,noselect',
|
||||
},
|
||||
|
||||
-- For an understanding of why these mappings were
|
||||
-- chosen, you will need to read `:help ins-completion`
|
||||
|
|
@ -725,6 +828,8 @@ require('lazy').setup({
|
|||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
-- Select the [p]revious item
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
-- ['<C-n>'] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select },
|
||||
-- ['<C-p>'] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select },
|
||||
|
||||
-- Scroll the documentation window [b]ack / [f]orward
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
|
|
@ -733,7 +838,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.
|
||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
||||
['<C-j>'] = cmp.mapping.confirm { select = true },
|
||||
|
||||
-- If you prefer more traditional completion keymaps,
|
||||
-- you can uncomment the following lines
|
||||
|
|
@ -782,64 +887,9 @@ require('lazy').setup({
|
|||
end,
|
||||
},
|
||||
|
||||
{ -- You can easily change to a different colorscheme.
|
||||
-- Change the name of the colorscheme plugin below, and then
|
||||
-- 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',
|
||||
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:
|
||||
vim.cmd.hi 'Comment gui=none'
|
||||
end,
|
||||
},
|
||||
|
||||
-- Highlight todo, notes, etc in comments
|
||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||
|
||||
{ -- Collection of various small independent plugins/modules
|
||||
'echasnovski/mini.nvim',
|
||||
config = function()
|
||||
-- Better Around/Inside textobjects
|
||||
--
|
||||
-- Examples:
|
||||
-- - va) - [V]isually select [A]round [)]paren
|
||||
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
|
||||
-- - ci' - [C]hange [I]nside [']quote
|
||||
require('mini.ai').setup { n_lines = 500 }
|
||||
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
--
|
||||
-- - 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()
|
||||
|
||||
-- Simple and easy statusline.
|
||||
-- You could remove this setup call if you don't like it,
|
||||
-- and try some other statusline plugin
|
||||
local statusline = require 'mini.statusline'
|
||||
-- set use_icons to true if you have a Nerd Font
|
||||
statusline.setup { use_icons = vim.g.have_nerd_font }
|
||||
|
||||
-- You can configure sections in the statusline by overriding their
|
||||
-- default behavior. For example, here we set the section for
|
||||
-- cursor location to LINE:COLUMN
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
statusline.section_location = function()
|
||||
return '%2l:%-2v'
|
||||
end
|
||||
|
||||
-- ... and there is more!
|
||||
-- Check out: https://github.com/echasnovski/mini.nvim
|
||||
end,
|
||||
},
|
||||
{ -- Highlight, edit, and navigate code
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = ':TSUpdate',
|
||||
|
|
@ -892,7 +942,7 @@ require('lazy').setup({
|
|||
--
|
||||
-- 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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
return {
|
||||
'akinsho/bufferline.nvim',
|
||||
version = '*',
|
||||
dependencies = 'nvim-tree/nvim-web-devicons',
|
||||
config = function()
|
||||
local bufferline = require 'bufferline'
|
||||
bufferline.setup {
|
||||
options = {
|
||||
separator_style = 'slope',
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
local function miniDeleteBuffer()
|
||||
local bd = require('mini.bufremove').delete
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(('Save changes to %q?'):format(vim.fn.bufname()), '&Yes\n&No\n&Cancel')
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
bd(0)
|
||||
elseif choice == 2 then -- No
|
||||
bd(0, true)
|
||||
end
|
||||
else
|
||||
bd(0)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
'echasnovski/mini.bufremove',
|
||||
keys = {
|
||||
{
|
||||
'<leader>bd',
|
||||
miniDeleteBuffer,
|
||||
desc = 'Delete Buffer',
|
||||
},
|
||||
{
|
||||
'œ',
|
||||
miniDeleteBuffer,
|
||||
desc = 'Delete Buffer',
|
||||
},
|
||||
-- stylua: ignore
|
||||
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
return {
|
||||
'folke/flash.nvim',
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
require('flash').setup()
|
||||
vim.keymap.set('n', 'f', '<cmd>lua require("flash").jump()<CR>', { noremap = true, desc = 'flash search' })
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'F',
|
||||
'<cmd>lua require("flash").jump({search = { forward = false, wrap = false, multi_window = false }})<CR>',
|
||||
{ noremap = true, desc = 'flash search backwards' }
|
||||
)
|
||||
end,
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
'FabijanZulj/blame.nvim',
|
||||
config = function()
|
||||
require('blame').setup()
|
||||
end,
|
||||
}
|
||||
|
|
@ -2,4 +2,39 @@
|
|||
-- I promise not to create any merge conflicts in this directory :)
|
||||
--
|
||||
-- See the kickstart.nvim README for more information
|
||||
return {}
|
||||
return {
|
||||
{
|
||||
'christoomey/vim-tmux-navigator',
|
||||
cmd = {
|
||||
'TmuxNavigateLeft',
|
||||
'TmuxNavigateDown',
|
||||
'TmuxNavigateUp',
|
||||
'TmuxNavigateRight',
|
||||
'TmuxNavigatePrevious',
|
||||
},
|
||||
keys = {
|
||||
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
|
||||
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
|
||||
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
|
||||
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
|
||||
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' },
|
||||
},
|
||||
},
|
||||
{
|
||||
'nxstynate/oneDarkPro.nvim',
|
||||
priority = 1000,
|
||||
opts = {
|
||||
palette_overrides = {
|
||||
dark0 = '#282c34',
|
||||
},
|
||||
},
|
||||
init = function()
|
||||
vim.cmd.colorscheme 'oneDarkPro'
|
||||
end,
|
||||
},
|
||||
{ 'NvChad/nvim-colorizer.lua', opts = {
|
||||
user_default_options = {
|
||||
css = true,
|
||||
},
|
||||
} },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
config = function()
|
||||
require('lualine').setup {}
|
||||
end,
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
branch = 'v3.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
|
||||
'MunifTanjim/nui.nvim',
|
||||
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
|
||||
},
|
||||
opts = {
|
||||
window = {
|
||||
width = 34,
|
||||
mappings = {
|
||||
['<C-v>'] = 'open_vsplit',
|
||||
['<C-x>'] = 'open_split',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
event = 'InsertEnter',
|
||||
config = true,
|
||||
-- use opts = {} for passing setup options
|
||||
-- this is equalent to setup({}) function
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
'MagicDuck/grug-far.nvim',
|
||||
config = function()
|
||||
require('grug-far').setup()
|
||||
vim.keymap.set('n', '<leader>sr', '<cmd>GrugFar<CR>', { desc = '[S]earch and [R]eplace' })
|
||||
end,
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
{
|
||||
'kylechui/nvim-surround',
|
||||
version = '*', -- Use for stability; omit to use `main` branch for the latest features
|
||||
event = 'VeryLazy',
|
||||
opts = {},
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue