1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-10-10 19:41:15 +02:00

nvim: added projection for session and project management

This commit is contained in:
2024-04-01 03:22:07 +02:00
parent 87b28a025c
commit 41e60ce12c
6 changed files with 90 additions and 33 deletions

View File

@@ -0,0 +1,30 @@
-- highlighting yanked regions
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
})
-- gnikdroy/projections.nvim
local Session = require("projections.session")
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
callback = function()
Session.store(vim.loop.cwd())
end,
})
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
if vim.fn.argc() ~= 0 then
return
end
local session_info = Session.info(vim.loop.cwd())
if session_info == nil then
Session.restore_latest()
else
Session.restore(vim.loop.cwd())
end
end,
desc = "Restore last session automatically",
})

View File

@@ -1,12 +1,3 @@
-- highlighting yanked regions
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
})
-- setup keymap function
local m = require 'mapx'.setup { global = true, whichkey = true }
@@ -16,6 +7,7 @@ m.nname("gp", "LSP: preview")
m.cname("w", "Write")
m.cname("w!", "Write: overwrite")
m.nname("<leader>g", "Git")
m.nname("<leader>f", "Telescope: find ...")
m.nname("<leader>gd", "Git: diff")
m.nname("<leader>s", "Substitute")
m.nname("<leader>t", "Terminal")
@@ -112,6 +104,7 @@ m.nnoremap("<F5>", function() require("renamer").rename() end, "LSP: rename")
-- nvim-telescope/telescope.nvim
m.nnoremap("<F4>", ':Telescope find_files<CR>', "Telescope: find files")
m.nnoremap("<leader>ff", ':Telescope find_files<CR>', "Telescope: find files")
-- kamykn/spelunker.vim
m.nnoremap("<F6>", ':call spelunker#toggle()<CR>', "Spelling: toggle spell check")
@@ -137,3 +130,6 @@ m.nnoremap("<C-W>m", ":WinShift<CR>", "Navigation: enter window shift mode")
m.nnoremap("s", "<Plug>(leap-forward)", "Navigation: enter leap mode for forward movement")
m.nnoremap("S", "<Plug>(leap-backward)", "Navigation: enter leap mode for backwards movement")
m.nnoremap("gs", "<Plug>(leap-from-window", "Navigation: enter leap mode for other windows")
-- gnikdroy/projections.nvim
m.nnoremap("<leader>fp", function() vim.cmd("Telescope projections") end, "Telescope: find projects")

View File

@@ -0,0 +1,24 @@
return {
"gnikdroy/projections.nvim",
dependencies = { "nvim-telescope/telescope.nvim" },
branch = "pre_release",
config = function()
require("projections").setup({
workspaces = { -- Default workspaces to search for
{ "~/code/main", { ".git" } },
{ "~/code/uni", { ".git" } },
},
store_hooks = {
pre = function()
-- nvim-tree
local nvim_tree_present, api = pcall(require, "nvim-tree.api")
if nvim_tree_present then
api.tree.close()
end
end,
},
})
require("telescope").load_extension("projections")
end,
}

View File

@@ -23,9 +23,9 @@ return {
wilder.python_file_finder_pipeline({
file_command = function(ctx, arg)
if string.find(arg, '.') ~= nil then
return {'fdfind', '-tf', '-H'}
return {'fd', '-tf', '-H'}
else
return {'fdfind', '-tf'}
return {'fd', '-tf'}
end
end,
dir_command = {'fd', '-td'},