diff options
Diffstat (limited to 'nvim')
24 files changed, 147 insertions, 124 deletions
diff --git a/nvim/.editorconfig b/nvim/.editorconfig new file mode 100644 index 0000000..2e6feec --- /dev/null +++ b/nvim/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = tab + diff --git a/nvim/init.lua b/nvim/init.lua index 87914ff..b0d2370 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,5 +1,5 @@ local fn = vim.fn -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +local install_path = fn.stdpath('config')..'/pack/packer/start/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) end @@ -14,3 +14,5 @@ require 'keymaps' require 'autocommands' require 'plugins' require 'lsp' + +vim.cmd [[colorscheme moonfly]] 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, + }, }) diff --git a/nvim/pack/packer/start/cmp-buffer b/nvim/pack/packer/start/cmp-buffer new file mode 160000 +Subproject b74fab3656eea9de20a9b8116afa3cfc4ec0965 diff --git a/nvim/pack/packer/start/cmp-nvim-lsp b/nvim/pack/packer/start/cmp-nvim-lsp new file mode 160000 +Subproject a8912b88ce488f411177fc8aed358b04dc246d7 diff --git a/nvim/pack/packer/start/cmp-path b/nvim/pack/packer/start/cmp-path new file mode 160000 +Subproject c6635aae33a50d6010bf1aa756ac2398a2d54c3 diff --git a/nvim/pack/packer/start/cmp-vsnip b/nvim/pack/packer/start/cmp-vsnip new file mode 160000 +Subproject 989a8a73c44e926199bfd05fa7a516d51f2d275 diff --git a/nvim/pack/packer/start/conform.nvim b/nvim/pack/packer/start/conform.nvim new file mode 160000 +Subproject 819c283db24211fd8ed2732b89a92ff9daa879b diff --git a/nvim/pack/packer/start/lualine.nvim b/nvim/pack/packer/start/lualine.nvim new file mode 160000 +Subproject 86fe39534b7da729a1ac56c0466e76f2c663dc4 diff --git a/nvim/pack/packer/start/nvim-cmp b/nvim/pack/packer/start/nvim-cmp new file mode 160000 +Subproject b5311ab3ed9c846b585c0c15b7559be131ec4be diff --git a/nvim/pack/nvim/start/nvim-lspconfig b/nvim/pack/packer/start/nvim-lspconfig -Subproject 32b6a6449aaba11461fffbb596dd6310af79eea +Subproject 32b6a6449aaba11461fffbb596dd6310af79eea diff --git a/nvim/pack/packer/start/nvim-tree.lua b/nvim/pack/packer/start/nvim-tree.lua new file mode 160000 +Subproject 3a63717d3d332d8f39aaf65be7a0e4c2265af02 diff --git a/nvim/pack/packer/start/nvim-treesitter b/nvim/pack/packer/start/nvim-treesitter new file mode 160000 +Subproject 684eeac91ed8e297685a97ef70031d19ac1de25 diff --git a/nvim/pack/packer/start/nvim-web-devicons b/nvim/pack/packer/start/nvim-web-devicons new file mode 160000 +Subproject 855c97005c8eebcdd19846f2e54706bffd40ee9 diff --git a/nvim/pack/nvim/start/packer.nvim b/nvim/pack/packer/start/packer.nvim -Subproject ea0cc3c59f67c440c5ff0bbe4fb9420f4350b9a +Subproject ea0cc3c59f67c440c5ff0bbe4fb9420f4350b9a diff --git a/nvim/pack/packer/start/plenary.nvim b/nvim/pack/packer/start/plenary.nvim new file mode 160000 +Subproject 857c5ac632080dba10aae49dba902ce3abf91b3 diff --git a/nvim/pack/packer/start/telescope.nvim b/nvim/pack/packer/start/telescope.nvim new file mode 160000 +Subproject a4ed82509cecc56df1c7138920a1aeaf246c0ac diff --git a/nvim/pack/packer/start/vim-moonfly-colors b/nvim/pack/packer/start/vim-moonfly-colors new file mode 160000 +Subproject bfa6b2486a72784b7546d0d3e9322aef70e07b0 diff --git a/nvim/pack/packer/start/vim-vsnip b/nvim/pack/packer/start/vim-vsnip new file mode 160000 +Subproject 0a4b8419e44f47c57eec4c90df17567ad4b1b36 |
