neovim part 6

This commit is contained in:
RafayAhmad7548 2025-05-05 22:56:56 +05:00
parent d8c82c966b
commit 97482df1a5
14 changed files with 258 additions and 194 deletions

View file

@ -1,5 +1,3 @@
local util = require('config.util')
-- NOTE: General --
-- hjkl to ijkl remap
@ -26,32 +24,27 @@ vim.keymap.set({ 'n', 'v', 'o' }, '#', '_', { desc = '# start of line' })
vim.keymap.set('n', '<C-s>', ':w<CR>', { desc = 'ctrl-s save' })
vim.keymap.set('n', '<C-w>', ':bd<CR>', { desc = 'save and close', nowait = true })
-- tabs
-- TODO: redo with telescope and ctrl tab
-- vim.keymap.set('n', '<leader><Tab>', ':bnext<CR>', { desc = 'next buffer' })
-- vim.keymap.set('n', '<leader><S-Tab>', ':bprev<CR>', { desc = 'previous buffer', noremap = true })
-- delete word in insert mode
vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'delete word in insert mode' })
-- NOTE: Right Dock: Terminal & Oil
-- NOTE: ctrl m
vim.keymap.set('n', '<F27>', '<cmd>Floaterminal<CR>', { desc = 'open terminal', nowait = true })
vim.keymap.set('t', '<F27>', '<cmd>q<CR>', { desc = 'close terminal window' })
vim.keymap.set('n', '<C-l>', function()
util.open_in_right_dock('term://')
end, { desc = 'open terminal' })
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', '<C-j>', '<cmd>wincmd h<CR>', { desc = 'focus editor', silent = true })
vim.keymap.set('t', '<C-w>', '<C-d>', { desc = 'kill terminal' })
vim.keymap.set('t', '<F28>', '<cmd>q<CR>', { desc = 'close terminal window' })
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'normal mode in terminal' })
vim.keymap.set('n', '<C-e>', function()
util.open_in_right_dock('oil://')
end, { desc = 'open oil' })
vim.keymap.set('n', '<C-e>', '<cmd>Floateroil<CR>', { desc = 'open oil' })
-- NOTE: Windows
@ -164,7 +157,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
--
-- This may be unwanted, since they displace some of your code
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
map('<leader>th', function()
map('<leader>ih', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end
@ -180,5 +173,9 @@ vim.keymap.set("n", "<leader>ml", ":MoltenEvaluateLine<CR>",
{ silent = true, desc = "evaluate line" })
vim.keymap.set("v", "<leader>mv", ":<C-u>MoltenEvaluateVisual<CR>gv",
{ silent = false, desc = "evaluate visual selection" })
vim.keymap.set("n", "<leader>mc", ":MoltenReevaluateCell<CR>",
{ silent = false, desc = "reevaluate cell" })
vim.keymap.set("n", "<leader>me", ":noautocmd MoltenEnterOutput<CR>",
{ silent = true, desc = "show/enter output" })
vim.keymap.set("n", "<leader>mh", ":MoltenHideOutput<CR>",
{ silent = true, desc = "hide output" })

View file

@ -44,7 +44,8 @@ vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.hlsearch = false
vim.opt.wrap = false
-- Example for configuring Neovim to load user-installed installed Lua rocks:
-- Example for configring Neovim to load user-installed installed Lua rocks:
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?/init.lua;'
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?.lua;'

View file

@ -7,6 +7,16 @@ return {
---@type AutoSession.Config
opts = {
suppressed_dirs = { '~/', '~/Downloads', '/' },
pre_save_cmds = {
function()
local bufs = vim.api.nvim_list_bufs()
for _, buf in ipairs(bufs) do
if vim.bo[buf].buftype == 'terminal' then
vim.api.nvim_buf_delete(buf, { force = true, unload = false })
end
end
end
},
pre_restore_cmds = {
-- might not be necessary, but save current harpoon data when we're about to restore a session
function() require('harpoon'):sync() end,

View file

@ -39,69 +39,116 @@ return {
},
{
"sindrets/diffview.nvim",
},
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
config = function()
require('neogit').setup({
kind = 'floating',
graph_style = 'kitty',
disable_line_numbers = false,
disable_relative_line_numbers = false,
commit_editor = {
kind = 'floating',
},
commit_select_view = {
kind = "floating",
},
commit_view = {
kind = "floating",
verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary
},
log_view = {
kind = "floating",
},
rebase_editor = {
kind = "floating",
},
reflog_view = {
kind = "floating",
},
merge_editor = {
kind = "floating",
},
description_editor = {
kind = "floating",
},
tag_editor = {
kind = "floating",
},
preview_buffer = {
kind = "floating",
},
popup = {
kind = "floating",
},
stash = {
kind = "floating",
},
refs_view = {
kind = "floating",
},
mappings = {
status = {
['i'] = 'MoveUp',
['k'] = 'MoveDown',
config = function ()
local actions = require('diffview.config').actions
require('diffview').setup({
keymaps = {
disable_defaults = true,
file_panel = {
['i'] = '<Up>',
['k'] = '<Down>',
['j'] = false,
},
['<Space>'] = function () actions.toggle_stage_entry() end
}
}
})
vim.keymap.set('n', '<leader>gg', '<cmd>Neogit<CR>', { desc = 'open neogit '})
end
}
},
-- {
-- "NeogitOrg/neogit",
-- dependencies = {
-- "nvim-lua/plenary.nvim",
-- "nvim-telescope/telescope.nvim",
-- },
-- config = function()
-- require('neogit').setup({
--
-- kind = 'floating',
-- graph_style = 'kitty',
-- disable_line_numbers = false,
-- disable_relative_line_numbers = false,
-- commit_editor = {
-- kind = 'floating',
-- },
-- commit_select_view = {
-- kind = "floating",
-- },
-- commit_view = {
-- kind = "floating",
-- verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary
-- },
-- log_view = {
-- kind = "floating",
-- },
-- rebase_editor = {
-- kind = "floating",
-- },
-- reflog_view = {
-- kind = "floating",
-- },
-- merge_editor = {
-- kind = "floating",
-- },
-- description_editor = {
-- kind = "floating",
-- },
-- tag_editor = {
-- kind = "floating",
-- },
-- preview_buffer = {
-- kind = "floating",
-- },
-- popup = {
-- kind = "floating",
-- },
-- stash = {
-- kind = "floating",
-- },
-- refs_view = {
-- kind = "floating",
-- },
-- mappings = {
-- status = {
-- ['i'] = 'MoveUp',
-- ['k'] = 'MoveDown',
-- ['j'] = false,
-- },
-- }
-- })
-- vim.keymap.set('n', '<leader>gg', '<cmd>Neogit<CR>', { desc = 'open neogit '})
-- end
-- }
-- {
-- 'tpope/vim-fugitive',
-- }
-- {
-- 'sindrets/diffview.nvim',
-- dependencies = { 'nvim-tree/nvim-web-devicons' },
-- -- lazy, only load diffview by these commands
-- cmd = {
-- 'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh'
-- }
-- },
-- {
-- 'SuperBo/fugit2.nvim',
-- build = false,
-- opts = {
-- width = 100,
-- },
-- dependencies = {
-- 'MunifTanjim/nui.nvim',
-- 'nvim-tree/nvim-web-devicons',
-- 'nvim-lua/plenary.nvim',
-- -- {
-- -- 'chrisgrieser/nvim-tinygit', -- optional: for Github PR view
-- -- dependencies = { 'stevearc/dressing.nvim' }
-- -- },
-- },
-- cmd = { 'Fugit2', 'Fugit2Diff', 'Fugit2Graph' },
-- keys = {
-- { '<leader>F', mode = 'n', '<cmd>Fugit2<cr>' }
-- }
-- },
}

View file

@ -16,10 +16,10 @@ return {
vim.keymap.set('n', '<leader>a', function() harpoon:list():add() end)
vim.keymap.set('n', '<C-h>', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
vim.keymap.set('n', '<A-1>', function() harpoon:list():select(1) end)
vim.keymap.set('n', '<A-2>', function() harpoon:list():select(2) end)
vim.keymap.set('n', '<A-3>', function() harpoon:list():select(3) end)
vim.keymap.set('n', '<A-q>', function() harpoon:list():select(4) end)
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)
-- -- Toggle previous & next buffers stored within Harpoon list
-- vim.keymap.set('n', '<C-S-P>', function() harpoon:list():prev() end)

View file

@ -41,12 +41,13 @@ require('lazy').setup({
require('config.plugins.ui'),
require('config.plugins.telescope'),
require('config.plugins.blinkcmp'),
require('config.plugins.lsp'),
require('config.plugins.treesitter'),
require('config.plugins.languages.lsp'),
require('config.plugins.languages.treesitter'),
require('config.plugins.harpoon'),
require('config.plugins.autosession'),
require('config.plugins.molten'),
require('config.plugins.languages.molten'),
require('config.plugins.languages.flutter'),
-- NOTE: maybe revisit this later

View file

@ -0,0 +1,11 @@
return {
'nvim-flutter/flutter-tools.nvim',
lazy = false,
dependencies = {
'nvim-lua/plenary.nvim',
'stevearc/dressing.nvim', -- optional for vim.ui.select
},
config = function()
require('flutter-tools').setup({})
end,
}

View file

@ -6,7 +6,7 @@ return {
opts = {
backend = 'kitty', -- whatever backend you would like to use
max_width = 100,
max_height = 12,
max_height = 20,
max_height_window_percentage = math.huge,
max_width_window_percentage = math.huge,
window_overlap_clear_enabled = true, -- toggles images when windows are overlapped
@ -22,7 +22,6 @@ return {
init = function()
-- these are examples, not defaults. Please see the readme
vim.g.molten_image_provider = 'image.nvim'
vim.g.molten_output_win_max_height = 20
end,
}
}

View file

@ -3,7 +3,7 @@ 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' },
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,

View file

@ -41,8 +41,15 @@ return {
vim.keymap.set('n', '<leader>ss', builtin.lsp_document_symbols, { desc = 'document symbols' })
vim.keymap.set('n', '<leader>sS', builtin.lsp_workspace_symbols, { desc = 'workspace symbols' })
vim.keymap.set('n', '<leader>st', '<cmd>TodoTelescope<CR>', { desc = 'search todos' })
vim.keymap.set('n', '<leader>sp', '<cmd>SessionSearch<CR>', { desc = 'search sessions' })
vim.keymap.set('n', '<leader>sh', function ()
builtin.help_tags({
previewer = false
})
end, { desc = 'help' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {

View file

@ -1,104 +0,0 @@
local function starts_with(str, prefix)
return string.find(str, '^' .. prefix) ~= nil
end
---get the window for the right dock
---@return integer | nil window window id if exists, nil otherwise
local function get_dock_win()
local windows = vim.api.nvim_list_wins()
for _, win in ipairs(windows) do
local width = vim.api.nvim_win_get_width(win)
if width == 60 or width == 40 then
return win
end
end
return nil
end
---get the buffer which starts with prefix
---@param prefix string prefix of the name of buffer
---@return integer | nil buf buffer id if exists, nil otherwise
local function get_dock_buf(prefix)
local buffers = vim.api.nvim_list_bufs()
for _, buf in ipairs(buffers) do
if vim.api.nvim_buf_is_loaded(buf) then
local buf_name = vim.api.nvim_buf_get_name(buf)
if starts_with(buf_name, prefix) then
return buf
end
end
end
return nil
end
---get number of windows that are not docks i.e. right dock
---@param tabpage integer tabpage id of the tab to look in, 0 for current
---@return integer count count of non-dock windows
local function get_no_of_nondock_wins(tabpage)
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
local count = 0
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
local buf_name = vim.api.nvim_buf_get_name(buf)
if not(starts_with(buf_name, 'term://') or starts_with(buf_name, 'oil://')) then
count = count + 1
end
end
return count
end
return {
open_in_right_dock = function (prefix)
-- set width accroding to terminal/oil
local width = prefix == 'term://' and 60 or 40
-- get dock window if exists
local dock_win = get_dock_win()
if dock_win ~= nil then
local buf = vim.api.nvim_win_get_buf(dock_win)
local buf_name = vim.api.nvim_buf_get_name(buf)
vim.api.nvim_set_current_win(dock_win)
vim.api.nvim_win_set_width(dock_win, width)
if starts_with(buf_name, prefix) then
if prefix == 'term://' then
vim.api.nvim_feedkeys('a', 'n', true)
end
else
if prefix == 'term://' then
vim.cmd.term()
vim.api.nvim_feedkeys('a', 'n', true)
else
vim.cmd('Oil')
end
end
return
end
-- no dock window at this point so create new
vim.cmd.vsplit()
vim.api.nvim_win_set_width(0, width)
-- get existing buf if exists
local dock_buf = get_dock_buf(prefix)
if dock_buf ~= nil then
vim.api.nvim_set_current_buf(dock_buf)
if prefix == 'term://' then
vim.api.nvim_feedkeys('a', 'n', true)
end
return
end
if prefix == 'term://' then
vim.cmd.term()
vim.api.nvim_feedkeys('a', 'n', true)
else
vim.cmd('Oil')
end
end,
}