diff options
| author | 2025-04-20 21:04:11 +0300 | |
|---|---|---|
| committer | 2025-04-20 21:04:11 +0300 | |
| commit | 020ed860340b1260258b6b8edbd4384e77ed3ecb (patch) | |
| tree | c11c75224397a285c23bdb54633b8e25484dfd5d /nvim/lua | |
| parent | 20.05.2025 (diff) | |
| download | dotfiles-020ed860340b1260258b6b8edbd4384e77ed3ecb.tar.gz dotfiles-020ed860340b1260258b6b8edbd4384e77ed3ecb.tar.bz2 dotfiles-020ed860340b1260258b6b8edbd4384e77ed3ecb.tar.xz dotfiles-020ed860340b1260258b6b8edbd4384e77ed3ecb.zip | |
20.05.2025 - 2
Diffstat (limited to 'nvim/lua')
| -rw-r--r-- | nvim/lua/autocommands.lua | 56 | ||||
| -rw-r--r-- | nvim/lua/keymaps.lua | 12 | ||||
| -rw-r--r-- | nvim/lua/options.lua | 66 | ||||
| -rw-r--r-- | nvim/lua/plugins/cmp.lua | 70 | ||||
| -rw-r--r-- | nvim/lua/plugins/init.lua | 32 | ||||
| -rw-r--r-- | nvim/lua/plugins/tree.lua | 24 |
6 files changed, 137 insertions, 123 deletions
diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua index a052a8c..8db58e7 100644 --- a/nvim/lua/autocommands.lua +++ b/nvim/lua/autocommands.lua @@ -1,46 +1,46 @@ vim.api.nvim_create_autocmd({'BufWritePre'}, { - pattern = '*.go', - callback = function() - local params = vim.lsp.util.make_range_params(nil, vim.lsp.util._get_offset_encoding()) - params.context = { only = {'source.organizeImports'} } - local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params, 3000) - for _, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - vim.lsp.util.apply_workspace_edit(r.edit, vim.lsp.util._get_offset_encoding()) - else - vim.lsp.buf.execute_command(r.command) - end - end - end - end, + pattern = '*.go', + callback = function() + local params = vim.lsp.util.make_range_params(nil, vim.lsp.util._get_offset_encoding()) + params.context = { only = {'source.organizeImports'} } + local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params, 3000) + for _, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + vim.lsp.util.apply_workspace_edit(r.edit, vim.lsp.util._get_offset_encoding()) + else + vim.lsp.buf.execute_command(r.command) + end + end + end + end, }) vim.api.nvim_create_autocmd({'BufWritePre'}, { - pattern = '*.go', - callback = function() - vim.lsp.buf.format(nil, 3000) - end + pattern = '*.go', + callback = function() + vim.lsp.buf.format(nil, 3000) + end }) local TrimWhiteSpaceGrp = vim.api.nvim_create_augroup('TrimWhiteSpaceGrp', {}) vim.api.nvim_create_autocmd('BufWritePre', { group = TrimWhiteSpaceGrp, - pattern = '*', - command = '%s/\\s\\+$//e', + pattern = '*', + command = '%s/\\s\\+$//e', }) local YankHighlightGrp = vim.api.nvim_create_augroup('YankHighlightGrp', {}) vim.api.nvim_create_autocmd('TextYankPost', { group = YankHighlightGrp, - pattern = '*', - callback = function() - vim.highlight.on_yank({ - higroup = 'IncSearch', - timeout = 40, - }) - end, + pattern = '*', + callback = function() + vim.highlight.on_yank({ + higroup = 'IncSearch', + timeout = 40, + }) + end, }) diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 6406100..75a11c4 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -15,9 +15,9 @@ map('v', 'i', '<S-i>', opts) map('v', 'a', '<S-a>', opts) -- Перемещение между буферами -kmap('n', '<leader>bn', ':bnext<CR>', { noremap = true, silent = true }) -- Следующий буфер -kmap('n', '<leader>bp', ':bprevious<CR>', { noremap = true, silent = true }) -- Предыдущий буфер -kmap('n', '<leader>bd', ':bdelete<CR>', { noremap = true, silent = true }) -- Закрыть текущий буфер +kmap('n', '<leader>bn', ':bnext<CR>', { noremap = true, silent = true }) -- Следующий буфер +kmap('n', '<leader>bp', ':bprevious<CR>', { noremap = true, silent = true }) -- Предыдущий буфер +kmap('n', '<leader>bd', ':bdelete<CR>', { noremap = true, silent = true }) -- Закрыть текущий буфер -- Tree map('n', '<C-t>', ':NvimTreeToggle<CR>', opts) @@ -52,9 +52,9 @@ kmap('n', 'gr', vim.lsp.buf.references, opts) -- kmap('n', '<leader>f', vim.lsp.buf.formatting, opts) local function change_root_to_global_cwd() - local api = require("nvim-tree.api") - local global_cwd = vim.fn.getcwd(-1, -1) - api.tree.change_root(global_cwd) + local api = require("nvim-tree.api") + local global_cwd = vim.fn.getcwd(-1, -1) + api.tree.change_root(global_cwd) end kmap('n', '<C-c>', change_root_to_global_cwd, {}) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua index 5f160a9..6f575a9 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/options.lua @@ -2,44 +2,44 @@ vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 local options = { - backup = false, -- creates a backup file - clipboard = "unnamedplus", -- allows neovim to access the system clipboard - cmdheight = 2, -- more space in the neovim command line for displaying messages - completeopt = { "menuone", "noselect" }, -- mostly just for cmp - conceallevel = 0, -- so that `` is visible in markdown files - fileencoding = "utf-8", -- the encoding written to a file - hidden = true, -- required to keep multiple buffers and open multiple buffers - hlsearch = true, -- highlight all matches on previous search pattern - ignorecase = true, -- ignore case in search patterns - mouse = "a", -- allow the mouse to be used in neovim - pumheight = 10, -- pop up menu height - showmode = false, -- we don't need to see things like -- INSERT -- anymore - showtabline = 2, -- always show tabs - smartcase = true, -- smart case - smartindent = true, -- make indenting smarter again - splitbelow = true, -- force all horizontal splits to go below current window - splitright = true, -- force all vertical splits to go to the right of current window - swapfile = false, -- creates a swapfile - termguicolors = true, -- set term gui colors (most terminals support this) - undofile = true, -- enable persistent undo - updatetime = 300, -- faster completion (4000ms default) - writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited - shiftwidth = 2, -- the number of spaces inserted for each indentation - tabstop = 2, -- insert 2 spaces for a tab - cursorline = true, -- highlight the current line - number = true, -- set numbered lines - relativenumber = false, -- set relative numbered lines - numberwidth = 4, -- set number column width to 2 {default 4} - signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time - wrap = false, -- display lines as one long line - scrolloff = 8, -- is one of my fav - sidescrolloff = 8, + backup = false, + clipboard = "unnamedplus", + cmdheight = 2, + completeopt = { "menuone", "noselect" }, + conceallevel = 0, + fileencoding = "utf-8", + hidden = true, + hlsearch = true, + ignorecase = true, + mouse = "a", + pumheight = 10, + showmode = false, + showtabline = 2, + smartcase = true, + smartindent = true, + splitbelow = true, + splitright = true, + swapfile = false, + termguicolors = true, + undofile = true, + updatetime = 300, + writebackup = false, + shiftwidth = 4, + tabstop = 4, + cursorline = true, + number = true, + relativenumber = true, + numberwidth = 4, + signcolumn = "yes", + wrap = true, + scrolloff = 8, + sidescrolloff = 8, } vim.opt.shortmess:append "c" for k, v in pairs(options) do - vim.opt[k] = v + vim.opt[k] = v end vim.cmd "set whichwrap+=<,>,[,],h,l" diff --git a/nvim/lua/plugins/cmp.lua b/nvim/lua/plugins/cmp.lua index 01fc505..923cb09 100644 --- a/nvim/lua/plugins/cmp.lua +++ b/nvim/lua/plugins/cmp.lua @@ -1,39 +1,39 @@ local cmp = require'cmp' cmp.setup{ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) - -- For `mini.snippets` users: - -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert - -- insert({ body = args.body }) -- Insert at cursor - -- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) - -- require("cmp.config").set_onetime({ sources = {} }) - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - ['<C-b>'] = cmp.mapping.scroll_docs(-4), - ['<C-f>'] = cmp.mapping.scroll_docs(4), - ['<C-Space>'] = cmp.mapping.complete(), - ['<C-e>'] = cmp.mapping.abort(), - ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. - }, { - { name = 'buffer' }, - }) + -- For `mini.snippets` users: + -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert + -- insert({ body = args.body }) -- Insert at cursor + -- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) + -- require("cmp.config").set_onetime({ sources = {} }) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) } diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index d21a585..f2f0676 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -1,7 +1,8 @@ -return require('packer').startup(function(use) +return require('packer').startup{function(use) use 'wbthomason/packer.nvim' use 'nvim-lua/plenary.nvim' use 'neovim/nvim-lspconfig' + use 'bluz71/vim-moonfly-colors' use { 'hrsh7th/nvim-cmp', requires = { @@ -15,12 +16,12 @@ return require('packer').startup(function(use) require 'plugins.cmp' end } - use { - 'nvim-lualine/lualine.nvim', - config = function() - require 'plugins.lualine' - end - } + use { + 'nvim-lualine/lualine.nvim', + config = function() + require 'plugins.lualine' + end + } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', @@ -36,12 +37,25 @@ return require('packer').startup(function(use) } use { 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', + }, config = function() require 'plugins.tree' end } - use 'nvim-tree/nvim-web-devicons' + use { + "stevearc/conform.nvim", + config = function() + require("conform").setup() + end, + } if packer_bootstrap then require('packer').sync() end -end) +end, +config = { + -- The root has to be a directory named "pack" + package_root = vim.fn.stdpath('config') .. '/pack', +}} + diff --git a/nvim/lua/plugins/tree.lua b/nvim/lua/plugins/tree.lua index 86cc36c..cea966e 100644 --- a/nvim/lua/plugins/tree.lua +++ b/nvim/lua/plugins/tree.lua @@ -1,14 +1,14 @@ require("nvim-tree").setup({ - sort = { - sorter = "case_sensitive", - }, - view = { - width = 30, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = true, - }, + sort = { + sorter = "case_sensitive", + }, + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, }) |
