neovim conf part 8, now with snacks and mini

This commit is contained in:
RafayAhmad7548 2025-05-12 20:14:01 +05:00
parent 36c7c39213
commit bbd1f9f7c1
13 changed files with 208 additions and 127 deletions

View file

@ -5,3 +5,10 @@ vim.api.nvim_create_autocmd('TextYankPost', {
vim.highlight.on_yank()
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
require('snacks').rename.on_rename_file(event.data.from, event.data.to)
end,
})

View file

@ -29,7 +29,7 @@ vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'delete word in insert mode' })
-- NOTE: Right Dock: Terminal & Oil
-- NOTE: Right Dock: Terminal & MiniOilFiles
-- NOTE: ctrl m
vim.keymap.set('n', '<F27>', '<cmd>Floaterminal<CR>', { desc = 'open terminal', nowait = true })
@ -37,23 +37,23 @@ vim.keymap.set('t', '<F27>', '<cmd>q<CR>', { desc = 'close terminal window' })
vim.keymap.set('t', '<C-l>', '<cmd>Floaterminal 1<CR>', { desc = 'terminal 1' })
vim.keymap.set('t', '<C-j>', '<cmd>Floaterminal 2<CR>', { desc = 'terminal 2' })
vim.keymap.set('t', '<C-f>', '<cmd>Floaterminal 3<CR>', { desc = 'terminal 3' })
vim.keymap.set('t', '<C-g>', '<cmd>Floaterminal 4<CR>', { desc = 'terminal 4' })
vim.keymap.set('t', '<Down>', '<cmd>Floaterminal 3<CR>', { desc = 'terminal 3' })
vim.keymap.set('t', '<Up>', '<cmd>Floaterminal 4<CR>', { desc = 'terminal 4' })
vim.keymap.set('t', '<C-w>', '<C-d>', { desc = 'kill terminal' })
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'normal mode in terminal' })
vim.keymap.set('n', '<C-e>', '<cmd>Floateroil<CR>', { desc = 'open oil' })
vim.keymap.set('n', '<C-e>', require('mini.files').open, { desc = 'open mini files' })
-- NOTE: Windows
-- this is weird because ctrl-i => Up & ctrl-k => Down in Kitty conf
vim.keymap.set({ 'n', 'v', 'o' }, '<Down><Up>', ':wincmd k<CR>', { desc = 'moving around window using ctrl-k ijkl', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<Down><Down>', ':wincmd j<CR>', { desc = 'moving around window using ctrl-k ijkl', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<Down><C-l>', ':wincmd l<CR>', { desc = 'moving around window using ctrl-k ijkl', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<Down><C-j>', ':wincmd h<CR>', { desc = 'moving around window using ctrl-k ijkl', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<leader>ki', ':wincmd k<CR>', { desc = 'move focus between windows', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<leader>kk', ':wincmd j<CR>', { desc = 'move focus between windows', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<leader>kl', ':wincmd l<CR>', { desc = 'move focus between windows', silent = true })
vim.keymap.set({ 'n', 'v', 'o' }, '<leader>kj', ':wincmd h<CR>', { desc = 'move focus between windows', silent = true })
-- NOTE: LSP
@ -75,7 +75,18 @@ vim.api.nvim_create_autocmd('LspAttach', {
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map('<F2>', vim.lsp.buf.rename, '[R]e[n]ame')
map('<F2>', function()
vim.api.nvim_exec_autocmds("User", { pattern = "SnacksInputRename" })
vim.lsp.buf.rename()
vim.api.nvim_create_autocmd("WinClosed", {
callback = function (args)
vim.api.nvim_exec_autocmds("User", {
pattern = "SnacksInputReset"
})
vim.api.nvim_del_autocmd(args.id)
end
})
end, '[R]e[n]ame')
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.

View file

@ -18,8 +18,8 @@ return {
vim.keymap.set('n', '<C-l>', function() harpoon:list():select(1) end)
vim.keymap.set('n', '<C-j>', function() harpoon:list():select(2) end)
vim.keymap.set('n', '<C-f>', function() harpoon:list():select(3) end)
vim.keymap.set('n', '<C-g>', function() harpoon:list():select(4) end)
vim.keymap.set('n', '<Down>', function() harpoon:list():select(3) end)
vim.keymap.set('n', '<Up>', function() harpoon:list():select(4) end)
-- -- Toggle previous & next buffers stored within Harpoon list
-- vim.keymap.set('n', '<C-S-P>', function() harpoon:list():prev() end)

View file

@ -15,28 +15,29 @@ vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
-- NOTE: General Editing --
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
{
'm4xshen/autoclose.nvim',
opts = {
keys = {
['%'] = { close = true, escape = true, pair = '%%', enabled_filetypes = { 'htmldjango' } },
},
options = { disable_when_touch = true, }
}
},
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = {} },
{
'lukas-reineke/indent-blankline.nvim',
main = 'ibl',
---@module 'ibl'
---@type ibl.config
opts = {},
},
-- TODO: i dunno about this one
-- {
-- "folke/noice.nvim",
-- event = "VeryLazy",
-- opts = {
-- },
-- dependencies = {
-- -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
-- "MunifTanjim/nui.nvim",
-- -- OPTIONAL:
-- -- `nvim-notify` is only needed, if you want to use the notification view.
-- -- If not available, we use `mini` as the fallback
-- "rcarriga/nvim-notify",
-- }
-- },
'ThePrimeagen/vim-be-good',
-- { 'stevearc/dressing.nvim', opts = {}, },
-- 'ThePrimeagen/vim-be-good',
-- { 'vuciv/golf' },
require('config.plugins.oil'),
require('config.plugins.git'),
require('config.plugins.ui'),
require('config.plugins.telescope'),
@ -45,20 +46,10 @@ require('lazy').setup({
require('config.plugins.languages.treesitter'),
require('config.plugins.harpoon'),
require('config.plugins.autosession'),
require('config.plugins.snacks'),
require('config.plugins.mini'),
require('config.plugins.languages.molten'),
require('config.plugins.languages.flutter'),
-- NOTE: maybe revisit this later
-- {
-- 'brenton-leighton/multiple-cursors.nvim',
-- version = '*', -- Use the latest tagged version
-- opts = {
-- custom_key_maps = keymaps.multicursor_custom()
-- }, -- This causes the plugin setup function to be called
-- keys = keymaps.multicursor(),
-- },
})

View file

@ -1,11 +1,10 @@
return {
'nvim-flutter/flutter-tools.nvim',
lazy = false,
dependencies = {
'nvim-lua/plenary.nvim',
'stevearc/dressing.nvim', -- optional for vim.ui.select
},
dependencies = { 'nvim-lua/plenary.nvim', },
config = function()
require('flutter-tools').setup({})
vim.keymap.set('n', '<leader>fd', '<cmd>FlutterDevices<CR>', { desc = 'show flutter devices' })
vim.keymap.set('n', '<leader>fq', '<cmd>FlutterQuit<CR>', { desc = 'stop flutter' })
end,
}

View file

@ -62,6 +62,7 @@ return {
emmet_language_server = {},
html = { filetypes = { 'html', 'htmldjango' }, },
cssls = {},
vtsls = {},
-- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--

View file

@ -3,15 +3,31 @@ return {
build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango', 'r', 'dart' },
auto_install = false,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
-- additional_vim_regex_highlighting = { 'ruby' },
ensure_installed = {
'bash',
'c',
'diff',
'html',
'css',
'lua',
'luadoc',
'markdown',
'markdown_inline',
'query',
'vim',
'vimdoc',
'rust',
'python',
'htmldjango',
'r',
'dart',
'javascript',
'typescript',
'tsx',
'regex'
},
auto_install = false,
highlight = { enable = true, },
indent = { enable = true },
},
-- There are additional nvim-treesitter modules that you can use to interact

View file

@ -0,0 +1,34 @@
return {
'echasnovski/mini.nvim',
version = '*' ,
config = function()
require('mini.pairs').setup({})
require('mini.ai').setup({
mappings = {
around = 'a',
inside = 'h',
around_next = 'an',
inside_next = 'hn',
around_last = 'al',
inside_last = 'hl',
goto_left = 'g[',
goto_right = 'g]',
},
silent = true,
})
require('mini.surround').setup({
silent = true,
})
require('mini.files').setup({
mappings = {
go_in = 'l',
go_out = 'j',
go_in_plus = 'L',
go_out_plus = 'J',
synchronize = '<C-s>'
}
})
end
}

View file

@ -1,51 +0,0 @@
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
use_default_keymaps = false,
buf_options = {
buflisted = true
},
keymaps = {
['<C-j>'] = { '<Down><C-j>', remap = true },
['<Space>'] = { callback = function()
local oil = require('oil')
local cursor_entry = oil.get_cursor_entry()
if not cursor_entry then
return
end
if cursor_entry.type == 'directory' then
oil.select()
else
oil.select(nil, function()
vim.cmd.wincmd('h')
local buf_name = vim.api.nvim_buf_get_name(0)
local is_empty = buf_name == '' and not vim.bo.modified
if is_empty then
-- delete empty buffer
vim.cmd('bd')
else
-- close window of not empty buffer
vim.cmd('q')
end
end)
end
end, nowait = true },
-- shift space remapping
['<F26>'] = 'actions.parent',
['<C-w>'] = { callback = function()
vim.cmd('bd')
end, nowait = true }
}
},
-- dependencies = { { 'echasnovski/mini.icons', opts = {} } },
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
}

View file

@ -0,0 +1,87 @@
return {
'folke/snacks.nvim',
priority = 1000,
lazy = false,
init = function()
local Snacks = require('snacks')
vim.api.nvim_create_autocmd("User", {
pattern = "SnacksInputRename",
callback = function ()
Snacks.config.input.win.relative = "cursor"
Snacks.config.input.win.col = -1
Snacks.config.input.win.row = -3
Snacks.config.input.win.title_pos = 'left'
end
})
vim.api.nvim_create_autocmd("User", {
pattern = "SnacksInputReset",
callback = function ()
Snacks.config.input.win.relative = "editor"
Snacks.config.input.win.col = nil
Snacks.config.input.win.row = 6
Snacks.config.input.win.title_pos = 'center'
end
})
end,
---@type snacks.Config
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
bigfile = { enabled = true },
dashboard = {
enabled = true,
preset = {
header = [[
]],
},
sections = {
{ section = 'header' },
{ section = 'startup' },
}
},
indent = {
enabled = true,
animate = { enabled = false },
},
input = {
enabled = true,
win = {},
},
quickfile = { enabled = true },
rename = { enabled = true },
bufdelete = { enabled = false },
debug = { enabled = false },
dim = { enabled = false },
explorer = { enabled = false },
git = { enabled = false },
gitbrowse = { enabled = false },
image = { enabled = false },
layout = { enabled = false },
lazygit = { enabled = false },
notifier = { enabled = false },
notify = { enabled = false },
picker = { enabled = false },
profiler = { enabled = false },
scope = { enabled = false },
scratch = { enabled = false },
scroll = { enabled = false },
statuscolumn = { enabled = false },
terminal = { enabled = false },
toggle = { enabled = false },
win = { enabled = false },
words = { enabled = false },
zed = { enabled = false },
},
}

View file

@ -10,6 +10,7 @@ return {
return vim.fn.executable 'make' == 1
end,
},
'nvim-telescope/telescope-ui-select.nvim',
},
config = function()
local actions = require('telescope.actions')
@ -28,9 +29,14 @@ return {
['<C-v>'] = actions.file_vsplit
}
}
},
extensions = {
['ui-select'] = { require('telescope.themes').get_dropdown({}) },
}
})
pcall(require('telescope').load_extension, 'fzf')
pcall(require("telescope").load_extension('ui-select'))
-- NOTE: Mappings --

View file

@ -1,22 +1,4 @@
return {
-- {
-- 'akinsho/bufferline.nvim',
-- version = "*",
-- dependencies = 'nvim-tree/nvim-web-devicons',
-- opts = {
-- options = {
-- custom_filter = function(buf, _)
-- local buf_name = vim.api.nvim_buf_get_name(buf)
-- if string.find(buf_name, '^term://') or string.find(buf_name, '^oil://') then
-- return false
-- end
-- return true
-- end,
-- show_buffer_close_icons = false,
-- -- style_preset = require('bufferline').style_preset.minimal
-- }
-- }
-- },
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },