20.05.2025
This commit is contained in:
parent
4bff377885
commit
57fc86a2cc
11 changed files with 126 additions and 86 deletions
|
@ -1,10 +1,26 @@
|
|||
local map = vim.api.nvim_set_keymap
|
||||
local kmap = vim.keymap.set
|
||||
local opts = {noremap = true, silent = true}
|
||||
|
||||
vim.g.mapleader = "\\"
|
||||
|
||||
map('n', '<Space>', '<Nop>', opts)
|
||||
map('n', '<Home>', '^', opts)
|
||||
map('n', '<End>', '$', opts)
|
||||
map('v', '<Home>', '^', opts)
|
||||
map('v', '<End>', '$', opts)
|
||||
map('i', '<Home>', '<C-o>^', opts)
|
||||
map('i', '<End>', '<C-o>$', opts)
|
||||
|
||||
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 }) -- Закрыть текущий буфер
|
||||
|
||||
-- Tree
|
||||
map('n', '<C-h>', ':NvimTreeToggle<CR>', opts)
|
||||
map('n', '<C-t>', ':NvimTreeToggle<CR>', opts)
|
||||
|
||||
-- Telescope
|
||||
map('n', '<leader>ff', '<cmd>Telescope find_files<CR>', opts)
|
||||
|
@ -12,34 +28,28 @@ map('n', '<leader>fg', '<cmd>Telescope live_grep<CR>', opts)
|
|||
map('n', '<leader>fb', '<cmd>Telescope buffers<CR>', opts)
|
||||
|
||||
-- LSP
|
||||
-- map('n', '<leader>e', vim.diagnostic.open_float, opts)
|
||||
-- map('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
-- map('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
-- map('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
||||
kmap('n', '<leader>e', vim.diagnostic.open_float, opts)
|
||||
kmap('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
kmap('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
kmap('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
|
||||
-- стандартные горячие клавиши для LSP, больше в документации
|
||||
-- https://github.com/neovim/nvim-lspconfig
|
||||
map('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
map('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
map('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
map('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
map('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
map('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
map('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
map('n', '<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
map('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
|
||||
map('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
|
||||
map('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
|
||||
map('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
map('n', '<leader>f', vim.lsp.buf.formatting, bufopts)
|
||||
end
|
||||
-- стандартные горячие клавиши для LSP, больше в документации
|
||||
-- https://github.com/neovim/nvim-lspconfig
|
||||
kmap('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
kmap('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
kmap('n', 'K', vim.lsp.buf.hover, opts)
|
||||
kmap('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
kmap('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
kmap('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
kmap('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
kmap('n', '<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
kmap('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||
kmap('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
kmap('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
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")
|
||||
|
@ -47,5 +57,5 @@ local function change_root_to_global_cwd()
|
|||
api.tree.change_root(global_cwd)
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<C-c>', change_root_to_global_cwd, {})
|
||||
kmap('n', '<C-c>', change_root_to_global_cwd, {})
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ local options = {
|
|||
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)
|
||||
timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||
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
|
||||
|
|
39
nvim/lua/plugins/cmp.lua
Normal file
39
nvim/lua/plugins/cmp.lua
Normal file
|
@ -0,0 +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+)
|
||||
|
||||
-- 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' },
|
||||
})
|
||||
}
|
|
@ -2,41 +2,25 @@ return require('packer').startup(function(use)
|
|||
use 'wbthomason/packer.nvim'
|
||||
use 'nvim-lua/plenary.nvim'
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-buffer'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
use {
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-vsnip',
|
||||
'hrsh7th/vim-vsnip',
|
||||
},
|
||||
config = function()
|
||||
require 'plugins.cmp'
|
||||
end
|
||||
}
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
config = function()
|
||||
require 'plugins.lualine'
|
||||
end
|
||||
}
|
||||
|
||||
-- движок сниппетов
|
||||
use {
|
||||
'L3MON4D3/LuaSnip',
|
||||
after = 'friendly-snippets',
|
||||
config = function()
|
||||
require('luasnip/loaders/from_vscode').load({
|
||||
paths = { '~/.local/share/nvim/site/pack/packer/start/friendly-snippets' }
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
-- автодополнения для сниппетов
|
||||
use 'saadparwaiz1/cmp_luasnip'
|
||||
|
||||
-- набор готовых сниппетов для всех языков, включая go
|
||||
use 'rafamadriz/friendly-snippets'
|
||||
|
||||
-- плагин для простого комментирования кода
|
||||
use {
|
||||
'numToStr/Comment.nvim',
|
||||
config = function()
|
||||
require('Comment').setup()
|
||||
end
|
||||
}
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate',
|
||||
|
@ -50,12 +34,6 @@ return require('packer').startup(function(use)
|
|||
require 'plugins.telescope'
|
||||
end
|
||||
}
|
||||
use {
|
||||
'olexsmir/gopher.nvim',
|
||||
config = function()
|
||||
-- require 'plugins.gopher'
|
||||
end
|
||||
}
|
||||
use {
|
||||
'nvim-tree/nvim-tree.lua',
|
||||
config = function()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue