add sessions and new keybindings

This commit is contained in:
Buliway 2025-01-07 14:42:01 +03:00
parent a83a413f14
commit 0bbadd9b09
7 changed files with 129 additions and 60 deletions

View file

@ -2,17 +2,23 @@
return {
{
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
'ray-x/go.nvim',
dependencies = { -- optional packages
'ray-x/guihua.lua',
'neovim/nvim-lspconfig',
'nvim-treesitter/nvim-treesitter',
},
config = function()
require("go").setup()
require('go').setup()
vim.keymap.set({ 'n' }, '<leader>gta', ':GoAddTag<CR>', { desc = '[G]o [T]ag [A]dd' })
vim.keymap.set({ 'n' }, '<leader>gtr', ':GoRmTag<CR>', { desc = '[G]o [T]ag [R]emove' })
vim.keymap.set({ 'n' }, '<leader>gfs', ':GoFillStruct<CR>', { desc = '[G]o [F]ill [S]truct' })
vim.keymap.set({ 'n' }, '<leader>gfc', ':GoFillSwitch<CR>', { desc = '[G]o [F]ill Switch [C]ase' })
vim.keymap.set({ 'n' }, '<leader>gie', ':GoIfErr<CR>', { desc = '[G]o [I]f [E]rr' })
vim.keymap.set({ 'n' }, '<leader>gfp', ':GoFixPlurals<CR>', { desc = '[G]o [F]ix [P]lurals' })
end,
event = {"CmdlineEnter"},
ft = {"go", 'gomod'},
event = { 'CmdlineEnter' },
ft = { 'go', 'gomod' },
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
}
},
}

View file

@ -0,0 +1,16 @@
-- A small automated session manager for Neovim
return {
{
'rmagatti/auto-session',
lazy = false,
---enables autocomplete for opts
---@module "auto-session"
---@type AutoSession.Config
opts = {
suppressed_dirs = { '~/', '~/Projects', '~/Downloads', '/' },
-- log_level = 'debug',
},
},
}

View file

@ -21,12 +21,12 @@ return {
-- `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',
@ -44,6 +44,7 @@ return {
luasnip.config.setup {}
cmp.setup {
preselect = cmp.PreselectMode.None,
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
@ -56,25 +57,38 @@ return {
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert {
-- (enabled by default in nvim-cmp)
-- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(),
-- ['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
-- 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-y>'] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- ['<CR>'] = cmp.mapping.confirm { select = true },
['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Allows Up arrow to fall back without interacting with cmp
['<Up>'] = cmp.mapping(function(fallback)
cmp.close()
fallback()
end, { 'i', 'c' }),
-- Allows Up arrow to fall back without interacting with cmp
['<Down>'] = cmp.mapping(function(fallback)
cmp.close()
fallback()
end, { 'i', 'c' }),
-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
@ -116,4 +130,4 @@ return {
}
end,
},
}
}

View file

@ -92,7 +92,8 @@ return {
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
-- Было <leader>ds [D]ocument [S]ymbols
map('<leader>S', require('telescope.builtin').lsp_document_symbols, 'Document [S]ymbols')
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
@ -153,12 +154,12 @@ return {
-- Change diagnostic symbols in the sign column (gutter)
if vim.g.have_nerd_font then
local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
local diagnostic_signs = {}
for type, icon in pairs(signs) do
diagnostic_signs[vim.diagnostic.severity[type]] = icon
end
vim.diagnostic.config { signs = { text = diagnostic_signs } }
local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
local diagnostic_signs = {}
for type, icon in pairs(signs) do
diagnostic_signs[vim.diagnostic.severity[type]] = icon
end
vim.diagnostic.config { signs = { text = diagnostic_signs } }
end
-- LSP servers and clients are able to communicate to each other what features they support.
@ -178,17 +179,18 @@ return {
-- - on_attach (func): Функция, которая вызывается, когда LSP подключается к буферу
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = { -- WARN: Качает через mason. Может не работать в NixOS. Оставил для других OS на будущее
-- See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- taplo
}
local servers =
{ -- WARN: Качает через mason. Может не работать в NixOS. Оставил для других OS на будущее
-- See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- taplo
}
local lspconfig = require('lspconfig')
local lspconfig = require 'lspconfig'
-- Nix
lspconfig.nixd.setup {}
@ -231,7 +233,6 @@ return {
end,
}
-- Lua
lspconfig.lua_ls.setup {
settings = {
@ -282,7 +283,6 @@ return {
lspconfig.vimls.setup {}
lspconfig.yamlls.setup {}
-- Ensure the servers and tools above are installed
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
@ -312,5 +312,5 @@ return {
},
}
end,
},
}
},
}

View file

@ -90,13 +90,16 @@ return {
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', '<leader><leader>', function()
builtin.buffers { sort_mru = true, ignore_current_buffer = true }
end, { desc = '[ ] Find etisting buffers' })
vim.keymap.set('n', '<leader>st', ':Telescope colorscheme<CR>', { desc = '[S]earch [T]hemes' })
-- 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.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
-- winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })

View file

@ -60,13 +60,15 @@ return {
-- Document existing key chains
spec = {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
-- { '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>g', group = '[G]olang' },
{ '<leader>gt', group = '[G]olang [T]ag' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
},
},
}
}

View file

@ -30,9 +30,23 @@ vim.opt.showmode = false
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function()
vim.opt.clipboard = 'unnamedplus'
end)
-- vim.schedule(function()
-- vim.opt.clipboard = 'unnamedplus'
-- end)
-- Use system clipboard via <leader>y/d, but Neovim clipboard via just y/d
vim.keymap.set('n', '<leader>y', '"+y', { desc = '[Y]ank to system clipboard' })
vim.keymap.set('v', '<leader>y', '"+y', { desc = '[Y]ank to system clipboard' })
-- vim.keymap.set('n', '<leader>Y', '"+Y', { desc = '[Y]ank to system clipboard' })
vim.keymap.set('n', '<leader>d', '"_d', { desc = '[D]elete to system clipboard' })
vim.keymap.set('v', '<leader>d', '"_d', { desc = '[D]elete to system clipboard' })
-- Change `K` hover documentation size
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
-- border = 'rounded',
max_width = 80,
-- max_height = 15,
})
-- Enable break indent
vim.opt.breakindent = true
@ -40,6 +54,15 @@ vim.opt.breakindent = true
-- Save undo history
vim.opt.undofile = true
-- Disable swap file
vim.opt.swapfile = false
-- Settings for sessions
vim.o.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions'
-- Highlight a vertical line at the specified column to encourage keeping lines within this limit
vim.opt.colorcolumn = '100'
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true
vim.opt.smartcase = true
@ -105,6 +128,11 @@ vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left wind
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- Use CTRL+arrows to switch between windows
vim.keymap.set('n', '<C-Left>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-Right>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-Down>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-Up>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
@ -113,9 +141,9 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})