diff --git a/nvim/lua/custom/plugins/golang.lua b/nvim/lua/custom/plugins/golang.lua index 2584e94..9edbb6b 100644 --- a/nvim/lua/custom/plugins/golang.lua +++ b/nvim/lua/custom/plugins/golang.lua @@ -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' }, 'gta', ':GoAddTag', { desc = '[G]o [T]ag [A]dd' }) + vim.keymap.set({ 'n' }, 'gtr', ':GoRmTag', { desc = '[G]o [T]ag [R]emove' }) + vim.keymap.set({ 'n' }, 'gfs', ':GoFillStruct', { desc = '[G]o [F]ill [S]truct' }) + vim.keymap.set({ 'n' }, 'gfc', ':GoFillSwitch', { desc = '[G]o [F]ill Switch [C]ase' }) + vim.keymap.set({ 'n' }, 'gie', ':GoIfErr', { desc = '[G]o [I]f [E]rr' }) + vim.keymap.set({ 'n' }, 'gfp', ':GoFixPlurals', { 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 - } + }, } diff --git a/nvim/lua/custom/plugins/sessions.lua b/nvim/lua/custom/plugins/sessions.lua new file mode 100644 index 0000000..ba4d10d --- /dev/null +++ b/nvim/lua/custom/plugins/sessions.lua @@ -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', + }, + }, +} diff --git a/nvim/lua/kickstart/plugins/completion.lua b/nvim/lua/kickstart/plugins/completion.lua index af44d26..5b0d3aa 100644 --- a/nvim/lua/kickstart/plugins/completion.lua +++ b/nvim/lua/kickstart/plugins/completion.lua @@ -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 - [''] = cmp.mapping.select_next_item(), + -- [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + -- [''] = 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. - [''] = cmp.mapping.confirm { select = true }, + -- [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + -- [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + + -- Allows Up arrow to fall back without interacting with cmp + [''] = cmp.mapping(function(fallback) + cmp.close() + fallback() + end, { 'i', 'c' }), + + -- Allows Up arrow to fall back without interacting with cmp + [''] = cmp.mapping(function(fallback) + cmp.close() + fallback() + end, { 'i', 'c' }), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = 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, }, -} \ No newline at end of file +} diff --git a/nvim/lua/kickstart/plugins/lsp.lua b/nvim/lua/kickstart/plugins/lsp.lua index a1a9553..695c852 100644 --- a/nvim/lua/kickstart/plugins/lsp.lua +++ b/nvim/lua/kickstart/plugins/lsp.lua @@ -92,7 +92,8 @@ return { -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + -- Было ds [D]ocument [S]ymbols + map('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, - }, -} \ No newline at end of file + }, +} diff --git a/nvim/lua/kickstart/plugins/telescope.lua b/nvim/lua/kickstart/plugins/telescope.lua index 0fd61dd..c6bf852 100644 --- a/nvim/lua/kickstart/plugins/telescope.lua +++ b/nvim/lua/kickstart/plugins/telescope.lua @@ -90,13 +90,16 @@ return { vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '', function() + builtin.buffers { sort_mru = true, ignore_current_buffer = true } + end, { desc = '[ ] Find etisting buffers' }) + vim.keymap.set('n', 'st', ':Telescope colorscheme', { desc = '[S]earch [T]hemes' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', 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' }) diff --git a/nvim/lua/kickstart/plugins/which-key.lua b/nvim/lua/kickstart/plugins/which-key.lua index 318aae6..8fd2e8e 100644 --- a/nvim/lua/kickstart/plugins/which-key.lua +++ b/nvim/lua/kickstart/plugins/which-key.lua @@ -60,13 +60,15 @@ return { -- Document existing key chains spec = { { 'c', group = '[C]ode', mode = { 'n', 'x' } }, - { 'd', group = '[D]ocument' }, + -- { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, + { 'g', group = '[G]olang' }, + { 'gt', group = '[G]olang [T]ag' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, }, -} \ No newline at end of file +} diff --git a/nvim/lua/kickstart/settings.lua b/nvim/lua/kickstart/settings.lua index 75c2777..743465a 100644 --- a/nvim/lua/kickstart/settings.lua +++ b/nvim/lua/kickstart/settings.lua @@ -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 y/d, but Neovim clipboard via just y/d +vim.keymap.set('n', 'y', '"+y', { desc = '[Y]ank to system clipboard' }) +vim.keymap.set('v', 'y', '"+y', { desc = '[Y]ank to system clipboard' }) +-- vim.keymap.set('n', 'Y', '"+Y', { desc = '[Y]ank to system clipboard' }) +vim.keymap.set('n', 'd', '"_d', { desc = '[D]elete to system clipboard' }) +vim.keymap.set('v', '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', '', '', { desc = 'Move focus to the left wind vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- Use CTRL+arrows to switch between windows +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -113,9 +141,9 @@ vim.keymap.set('n', '', '', { 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, -}) \ No newline at end of file + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +})