add sessions and new keybindings
This commit is contained in:
parent
a83a413f14
commit
0bbadd9b09
7 changed files with 129 additions and 60 deletions
|
|
@ -2,17 +2,23 @@
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"ray-x/go.nvim",
|
'ray-x/go.nvim',
|
||||||
dependencies = { -- optional packages
|
dependencies = { -- optional packages
|
||||||
"ray-x/guihua.lua",
|
'ray-x/guihua.lua',
|
||||||
"neovim/nvim-lspconfig",
|
'neovim/nvim-lspconfig',
|
||||||
"nvim-treesitter/nvim-treesitter",
|
'nvim-treesitter/nvim-treesitter',
|
||||||
},
|
},
|
||||||
config = function()
|
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,
|
end,
|
||||||
event = {"CmdlineEnter"},
|
event = { 'CmdlineEnter' },
|
||||||
ft = {"go", 'gomod'},
|
ft = { 'go', 'gomod' },
|
||||||
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
|
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
nvim/lua/custom/plugins/sessions.lua
Normal file
16
nvim/lua/custom/plugins/sessions.lua
Normal 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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -21,12 +21,12 @@ return {
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
-- See the README about individual language/framework/plugin snippets:
|
-- See the README about individual language/framework/plugin snippets:
|
||||||
-- https://github.com/rafamadriz/friendly-snippets
|
-- https://github.com/rafamadriz/friendly-snippets
|
||||||
-- {
|
{
|
||||||
-- 'rafamadriz/friendly-snippets',
|
'rafamadriz/friendly-snippets',
|
||||||
-- config = function()
|
config = function()
|
||||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
-- end,
|
end,
|
||||||
-- },
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
|
@ -44,6 +44,7 @@ return {
|
||||||
luasnip.config.setup {}
|
luasnip.config.setup {}
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
|
preselect = cmp.PreselectMode.None,
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
|
|
@ -56,25 +57,38 @@ return {
|
||||||
--
|
--
|
||||||
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
-- (enabled by default in nvim-cmp)
|
||||||
-- Select the [n]ext item
|
-- Select the [n]ext item
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
-- ['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
-- Select the [p]revious item
|
-- Select the [p]revious item
|
||||||
['<C-p>'] = cmp.mapping.select_prev_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),
|
|
||||||
|
|
||||||
-- Accept ([y]es) the completion.
|
-- Accept ([y]es) the completion.
|
||||||
-- This will auto-import if your LSP supports it.
|
-- This will auto-import if your LSP supports it.
|
||||||
-- This will expand snippets if the LSP sent a snippet.
|
-- 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,
|
-- If you prefer more traditional completion keymaps,
|
||||||
-- you can uncomment the following lines
|
-- you can uncomment the following lines
|
||||||
--['<CR>'] = cmp.mapping.confirm { select = true },
|
-- ['<CR>'] = cmp.mapping.confirm { select = true },
|
||||||
--['<Tab>'] = cmp.mapping.select_next_item(),
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
--['<S-Tab>'] = cmp.mapping.select_prev_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.
|
-- Manually trigger a completion from nvim-cmp.
|
||||||
-- Generally you don't need this, because nvim-cmp will display
|
-- Generally you don't need this, because nvim-cmp will display
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,8 @@ return {
|
||||||
|
|
||||||
-- Fuzzy find all the symbols in your current document.
|
-- Fuzzy find all the symbols in your current document.
|
||||||
-- Symbols are things like variables, functions, types, etc.
|
-- 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.
|
-- Fuzzy find all the symbols in your current workspace.
|
||||||
-- Similar to document symbols, except searches over your entire project.
|
-- Similar to document symbols, except searches over your entire project.
|
||||||
|
|
@ -153,12 +154,12 @@ return {
|
||||||
|
|
||||||
-- Change diagnostic symbols in the sign column (gutter)
|
-- Change diagnostic symbols in the sign column (gutter)
|
||||||
if vim.g.have_nerd_font then
|
if vim.g.have_nerd_font then
|
||||||
local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
|
local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
|
||||||
local diagnostic_signs = {}
|
local diagnostic_signs = {}
|
||||||
for type, icon in pairs(signs) do
|
for type, icon in pairs(signs) do
|
||||||
diagnostic_signs[vim.diagnostic.severity[type]] = icon
|
diagnostic_signs[vim.diagnostic.severity[type]] = icon
|
||||||
end
|
end
|
||||||
vim.diagnostic.config { signs = { text = diagnostic_signs } }
|
vim.diagnostic.config { signs = { text = diagnostic_signs } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- LSP servers and clients are able to communicate to each other what features they support.
|
-- LSP servers and clients are able to communicate to each other what features they support.
|
||||||
|
|
@ -178,17 +179,18 @@ return {
|
||||||
-- - on_attach (func): Функция, которая вызывается, когда LSP подключается к буферу
|
-- - on_attach (func): Функция, которая вызывается, когда LSP подключается к буферу
|
||||||
-- - settings (table): Override the default settings passed when initializing the server.
|
-- - 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/
|
-- 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 на будущее
|
local servers =
|
||||||
-- See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
{ -- 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
|
-- 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
|
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||||
}
|
-- taplo
|
||||||
|
}
|
||||||
|
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require 'lspconfig'
|
||||||
|
|
||||||
-- Nix
|
-- Nix
|
||||||
lspconfig.nixd.setup {}
|
lspconfig.nixd.setup {}
|
||||||
|
|
@ -231,7 +233,6 @@ return {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Lua
|
-- Lua
|
||||||
lspconfig.lua_ls.setup {
|
lspconfig.lua_ls.setup {
|
||||||
settings = {
|
settings = {
|
||||||
|
|
@ -282,7 +283,6 @@ return {
|
||||||
lspconfig.vimls.setup {}
|
lspconfig.vimls.setup {}
|
||||||
lspconfig.yamlls.setup {}
|
lspconfig.yamlls.setup {}
|
||||||
|
|
||||||
|
|
||||||
-- Ensure the servers and tools above are installed
|
-- Ensure the servers and tools above are installed
|
||||||
-- To check the current status of installed tools and/or manually install
|
-- To check the current status of installed tools and/or manually install
|
||||||
-- other tools, you can run
|
-- other tools, you can run
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,16 @@ return {
|
||||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
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>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>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
|
-- Slightly advanced example of overriding default behavior and theme
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||||
winblend = 10,
|
-- winblend = 10,
|
||||||
previewer = false,
|
previewer = false,
|
||||||
})
|
})
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,13 @@ return {
|
||||||
-- Document existing key chains
|
-- Document existing key chains
|
||||||
spec = {
|
spec = {
|
||||||
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
|
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
|
||||||
{ '<leader>d', group = '[D]ocument' },
|
-- { '<leader>d', group = '[D]ocument' },
|
||||||
{ '<leader>r', group = '[R]ename' },
|
{ '<leader>r', group = '[R]ename' },
|
||||||
{ '<leader>s', group = '[S]earch' },
|
{ '<leader>s', group = '[S]earch' },
|
||||||
{ '<leader>w', group = '[W]orkspace' },
|
{ '<leader>w', group = '[W]orkspace' },
|
||||||
{ '<leader>t', group = '[T]oggle' },
|
{ '<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' } },
|
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,23 @@ vim.opt.showmode = false
|
||||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||||
-- Remove this option if you want your OS clipboard to remain independent.
|
-- Remove this option if you want your OS clipboard to remain independent.
|
||||||
-- See `:help 'clipboard'`
|
-- See `:help 'clipboard'`
|
||||||
vim.schedule(function()
|
-- vim.schedule(function()
|
||||||
vim.opt.clipboard = 'unnamedplus'
|
-- vim.opt.clipboard = 'unnamedplus'
|
||||||
end)
|
-- 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
|
-- Enable break indent
|
||||||
vim.opt.breakindent = true
|
vim.opt.breakindent = true
|
||||||
|
|
@ -40,6 +54,15 @@ vim.opt.breakindent = true
|
||||||
-- Save undo history
|
-- Save undo history
|
||||||
vim.opt.undofile = true
|
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
|
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
|
||||||
vim.opt.ignorecase = true
|
vim.opt.ignorecase = true
|
||||||
vim.opt.smartcase = 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-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-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' })
|
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 ]]
|
-- [[ Basic Autocommands ]]
|
||||||
-- See `:help lua-guide-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
|
-- Try it with `yap` in normal mode
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
desc = 'Highlight when yanking (copying) text',
|
desc = 'Highlight when yanking (copying) text',
|
||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
Loading…
Add table
Reference in a new issue