plugins, keymaps + fix formatting

This commit is contained in:
Noah Håkansson 2024-01-30 10:38:13 +01:00
parent ec6733a0ea
commit b402f79541
10 changed files with 220 additions and 43 deletions

View file

@ -12,7 +12,7 @@ function M.config()
auto_preview = true,
show_title = true,
delay_syntax = 50,
wrap = false,
wrap = true,
},
func_map = {
tab = 't',

View file

@ -19,12 +19,25 @@ function M.config()
formatting.stylua,
formatting.black,
formatting.prettier.with({
extra_filetypes = { 'toml' },
filetypes = {
'css',
'scss',
'less',
'html',
'json',
'jsonc',
'yaml',
'toml',
'markdown',
'markdown.mdx',
'graphql',
'handlebars',
},
-- extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
}),
formatting.eslint_d,
diagnostics.eslint_d,
null_ls.builtins.diagnostics.flake8,
diagnostics.flake8,
-- diagnostics.flake8,
code_actions.eslint_d,
},

View file

@ -0,0 +1,65 @@
--
-- better session management with git branch support
--
local M = {
'olimorris/persisted.nvim',
lazy = false,
}
function M.config()
require('persisted').setup({
save_dir = vim.fn.expand(vim.fn.stdpath('data') .. '/sessions/'), -- directory where session files are saved: Resolves to ~/.local/share/lvim/sessions/
silent = false, -- silent nvim message when sourcing session file
use_git_branch = true, -- create session files based on the branch of the git enabled repository
autosave = true, -- automatically save session files when exiting Neovim
should_autosave = function() -- function to determine if a session should be autosaved
-- do not autosave if the current filetype is ""(empty buffer), NvimTree or alpha
if vim.bo.filetype == '' or vim.bo.filetype == 'NvimTree' or vim.bo.filetype == 'alpha' then
return false
end
return true
end,
autoload = true, -- automatically load the session for the cwd on Neovim startup
on_autoload_no_session = function() -- function to run when `autoload = true` but there is no session to load
end,
follow_cwd = true, -- change session file name to match current working directory if it changes
allowed_dirs = {
'~/Flexfiles',
'~/projects',
'~/work',
}, -- table of dirs that the plugin will auto-save and auto-load from
ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading
telescope = { -- options for the telescope extension
reset_prompt_after_deletion = true, -- whether to reset prompt after session deleted
},
})
end
-- persisted autocommands
local persistedGroup = vim.api.nvim_create_augroup('PersistedHooks', { clear = true })
-- close NvimTree and DiffView(git) before saving session
vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'PersistedSavePre',
group = persistedGroup,
callback = function()
pcall(vim.cmd, 'NvimTreeClose')
pcall(vim.cmd, 'DiffviewClose')
end,
})
-- close empty buffers before saving session
vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'PersistedSavePre',
group = persistedGroup,
callback = function()
local buflist = vim.fn.getbufinfo({ buflisted = 1 })
for _, buf in ipairs(buflist) do
if buf.name == '' then
vim.api.nvim_buf_delete(buf.bufnr, { force = false })
end
end
end,
})
return M

View file

@ -0,0 +1,28 @@
local M = {
'cshuaimin/ssr.nvim',
lazy = true,
}
function M.config()
require('ssr').setup({
border = 'rounded',
min_width = 50,
min_height = 5,
max_width = 120,
max_height = 25,
adjust_window = true,
keymaps = {
close = 'q',
next_match = 'n',
prev_match = 'N',
replace_confirm = '<cr>',
replace_all = '<leader><cr>',
},
})
end
vim.keymap.set({ 'n', 'x' }, '<leader>r', function()
require('ssr').open()
end)
return M

View file

@ -0,0 +1,32 @@
local M = {
'jiaoshijie/undotree',
dependencies = 'nvim-lua/plenary.nvim',
config = true,
keys = { -- load the plugin only when using it's keybinding:
{ '<leader>u', "<cmd>lua require('undotree').toggle()<cr>" },
},
}
function M.config()
require('undotree').setup({
float_diff = true, -- using float window previews diff, set this `true` will disable layout option
layout = 'left_bottom', -- "left_bottom", "left_left_bottom"
position = 'left', -- "right", "bottom"
ignore_filetype = { 'NvimTree', 'fugitive', 'undotree', 'undotreeDiff', 'qf', 'TelescopePrompt', 'spectre_panel', 'tsplayground' },
window = {
winblend = 30,
},
keymaps = {
['j'] = 'move_next',
['k'] = 'move_prev',
['gj'] = 'move2parent',
['J'] = 'move_change_next',
['K'] = 'move_change_prev',
['<cr>'] = 'action_enter',
['p'] = 'enter_diffbuf',
['q'] = 'quit',
},
})
end
return M