ref(nvim): centrilized plugin configuration
This commit is contained in:
parent
48822c5847
commit
7a56c0a1d3
@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
local status, autosave = pcall(require, "auto-save")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
autosave.setup(
|
|
||||||
{
|
|
||||||
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
|
|
||||||
execution_message = {
|
|
||||||
message = function() -- message to print on save
|
|
||||||
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
|
|
||||||
end,
|
|
||||||
dim = 0.18, -- dim the color of `message`
|
|
||||||
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
|
|
||||||
},
|
|
||||||
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
|
|
||||||
-- function that determines whether to save the current buffer or not
|
|
||||||
-- return true: if buffer is ok to be saved
|
|
||||||
-- return false: if it's not ok to be saved
|
|
||||||
condition = function(buf)
|
|
||||||
local fn = vim.fn
|
|
||||||
local utils = require("auto-save.utils.data")
|
|
||||||
|
|
||||||
if
|
|
||||||
fn.getbufvar(buf, "&modifiable") == 1 and
|
|
||||||
utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
|
|
||||||
return true -- met condition(s), can save
|
|
||||||
end
|
|
||||||
return false -- can't save
|
|
||||||
end,
|
|
||||||
write_all_buffers = false, -- write all buffers when the current one meets `condition`
|
|
||||||
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
|
|
||||||
callbacks = { -- functions to be executed at different intervals
|
|
||||||
enabling = nil, -- ran when enabling auto-save
|
|
||||||
disabling = nil, -- ran when disabling auto-save
|
|
||||||
before_asserting_save = nil, -- ran before checking `condition`
|
|
||||||
before_saving = nil, -- ran before doing the actual save
|
|
||||||
after_saving = nil -- ran after doing the actual save
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
local status, cmp = pcall(require, "cmp")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
local function has_words_before()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local border_opts = {
|
|
||||||
border = "single",
|
|
||||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
|
|
||||||
}
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
completion = {
|
|
||||||
autocomplete = false
|
|
||||||
},
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = {
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-e>'] = cmp.mapping.close(),
|
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
window = {
|
|
||||||
completion = cmp.config.window.bordered(border_opts),
|
|
||||||
documentation = cmp.config.window.bordered(border_opts),
|
|
||||||
},
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'nvim_lsp', priority = 1000 },
|
|
||||||
{ name = 'luasnip', priority = 750 },
|
|
||||||
{ name = 'buffer', priority = 500 },
|
|
||||||
{ name = 'path', priority = 250 },
|
|
||||||
}, {
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
|
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup.cmdline(':', {
|
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'path' }
|
|
||||||
}, {
|
|
||||||
{ name = 'cmdline' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
local status, colorscheme = pcall(require, "nightfox")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
colorscheme.compile()
|
|
||||||
|
|
||||||
colorscheme.setup()
|
|
||||||
|
|
||||||
vim.cmd.colorscheme("nightfox")
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
local status, comment = pcall(require, 'Comment')
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
comment.setup()
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
local status, gitsigns = pcall(require, "gitsigns")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
gitsigns.setup()
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
local status, nvim_lsp = pcall(require, "lspconfig")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
|
||||||
-- after the language server attaches to the current buffer
|
|
||||||
local on_attach = function(client, bufnr)
|
|
||||||
|
|
||||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
||||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
||||||
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
|
||||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
||||||
|
|
||||||
-- Mappings.
|
|
||||||
local opts = { noremap=true, silent=true }
|
|
||||||
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
||||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
||||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
||||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
||||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
||||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
||||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
||||||
-- map buffer local keybindings when the language server attaches
|
|
||||||
local servers = { 'pyright', 'lua_ls', 'rust_analyzer' }
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
nvim_lsp[lsp].setup {
|
|
||||||
on_attach = on_attach,
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
||||||
|
|
||||||
nvim_lsp.clangd.setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
local status, lualine = pcall(require, "lualine")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
lualine.setup()
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
local status, ls = pcall(require, "luasnip")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
vim.g.snips_author = 'thek4n'
|
|
||||||
vim.g.snips_email = 'thek4n@yandex.com'
|
|
||||||
vim.g.snips_github = 'https://github.com/thek4n'
|
|
||||||
|
|
||||||
|
|
||||||
local function jump(val)
|
|
||||||
return function()
|
|
||||||
ls.jump(val)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local map = vim.keymap.set
|
|
||||||
map({'i', 's'}, '<C-n>', jump(1))
|
|
||||||
map({'i', 's'}, '<C-p>', jump(-1))
|
|
||||||
|
|
||||||
|
|
||||||
local status_loader, luasnip_loaders = pcall(require, "luasnip.loaders.from_snipmate")
|
|
||||||
if (not status_loader) then return end
|
|
||||||
|
|
||||||
luasnip_loaders.lazy_load()
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
local status, mason_lspconfig = pcall(require, "mason-lspconfig")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
mason_lspconfig.setup()
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
local status, mason = pcall(require, "mason")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
mason.setup()
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
local status, nvim_autopairs = pcall(require, "nvim-autopairs")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
nvim_autopairs.setup()
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
local status, nvim_treesitter = pcall(require, "nvim-treesitter.configs")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
nvim_treesitter.setup {
|
|
||||||
ensure_installed = {"python", "lua", "vim", "html", "rust", "markdown"},
|
|
||||||
auto_install = true,
|
|
||||||
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
local status, nvim_ts_autotag = pcall(require, "nvim-ts-autotag")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
|
|
||||||
nvim_ts_autotag.setup()
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
|
|
||||||
local status, telescope = pcall(require, "telescope")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
telescope.load_extension('fzf')
|
|
||||||
|
|
||||||
telescope.setup {
|
|
||||||
defaults = {
|
|
||||||
selection_caret = " ",
|
|
||||||
path_display = { "smart" },
|
|
||||||
file_ignore_patterns = {
|
|
||||||
".git/",
|
|
||||||
"target/",
|
|
||||||
"docs/",
|
|
||||||
"vendor/*",
|
|
||||||
"%.lock",
|
|
||||||
"pycache/*",
|
|
||||||
"%.sqlite3",
|
|
||||||
"%.ipynb",
|
|
||||||
"node_modules/*",
|
|
||||||
"%.svg",
|
|
||||||
"%.otf",
|
|
||||||
"%.ttf",
|
|
||||||
"%.webp",
|
|
||||||
".dart_tool/",
|
|
||||||
".github/",
|
|
||||||
".gradle/",
|
|
||||||
".idea/",
|
|
||||||
".settings/",
|
|
||||||
".vscode/",
|
|
||||||
"pycache/",
|
|
||||||
"build/",
|
|
||||||
"env/",
|
|
||||||
"gradle/",
|
|
||||||
"node_modules/",
|
|
||||||
"%.pdb",
|
|
||||||
"%.dll",
|
|
||||||
"%.class",
|
|
||||||
"%.exe",
|
|
||||||
"%.cache",
|
|
||||||
"%.ico",
|
|
||||||
"%.pdf",
|
|
||||||
"%.dylib",
|
|
||||||
"%.jar",
|
|
||||||
"%.docx",
|
|
||||||
"%.met",
|
|
||||||
"smalljre_*/*",
|
|
||||||
".vale/",
|
|
||||||
"%.burp",
|
|
||||||
"%.mp4",
|
|
||||||
"%.mkv",
|
|
||||||
"%.rar",
|
|
||||||
"%.zip",
|
|
||||||
"%.7z",
|
|
||||||
"%.tar",
|
|
||||||
"%.bz2",
|
|
||||||
"%.epub",
|
|
||||||
"%.flac",
|
|
||||||
"%.tar.gz",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
local status, trouble = pcall(require, "trouble")
|
|
||||||
if (not status) then return end
|
|
||||||
|
|
||||||
trouble.setup()
|
|
||||||
35
home/user/.config/nvim/lua/base/plugins/auto_save.lua
Normal file
35
home/user/.config/nvim/lua/base/plugins/auto_save.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
return {
|
||||||
|
'Pocco81/auto-save.nvim',
|
||||||
|
config = function()
|
||||||
|
require("auto-save").setup({
|
||||||
|
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
|
||||||
|
execution_message = {
|
||||||
|
message = function() -- message to print on save
|
||||||
|
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
|
||||||
|
end,
|
||||||
|
dim = 0.18, -- dim the color of `message`
|
||||||
|
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
|
||||||
|
},
|
||||||
|
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
|
||||||
|
condition = function(buf)
|
||||||
|
local fn = vim.fn
|
||||||
|
local utils = require("auto-save.utils.data")
|
||||||
|
if
|
||||||
|
fn.getbufvar(buf, "&modifiable") == 1 and
|
||||||
|
utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
|
||||||
|
return true -- met condition(s), can save
|
||||||
|
end
|
||||||
|
return false -- can't save
|
||||||
|
end,
|
||||||
|
write_all_buffers = false, -- write all buffers when the current one meets `condition`
|
||||||
|
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
|
||||||
|
callbacks = { -- functions to be executed at different intervals
|
||||||
|
enabling = nil, -- ran when enabling auto-save
|
||||||
|
disabling = nil, -- ran when disabling auto-save
|
||||||
|
before_asserting_save = nil, -- ran before checking `condition`
|
||||||
|
before_saving = nil, -- ran before doing the actual save
|
||||||
|
after_saving = nil -- ran after doing the actual save
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
}
|
||||||
@ -1,6 +1,12 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'EdenEast/nightfox.nvim'
|
'EdenEast/nightfox.nvim',
|
||||||
|
config = function()
|
||||||
|
local colorscheme = require("nightfox")
|
||||||
|
colorscheme.compile()
|
||||||
|
colorscheme.setup()
|
||||||
|
vim.cmd.colorscheme("nightfox")
|
||||||
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'ellisonleao/gruvbox.nvim'
|
'ellisonleao/gruvbox.nvim'
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-lualine/lualine.nvim',
|
'nvim-lualine/lualine.nvim',
|
||||||
|
config = function()
|
||||||
|
require("lualine").setup()
|
||||||
|
end,
|
||||||
dependencies = { 'kyazdani42/nvim-web-devicons' }
|
dependencies = { 'kyazdani42/nvim-web-devicons' }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
dependencies = "williamboman/mason-lspconfig.nvim"
|
dependencies = {
|
||||||
|
{
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
config = function()
|
||||||
|
require("mason-lspconfig").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("mason").setup()
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,33 @@ return {
|
|||||||
'tpope/vim-repeat',
|
'tpope/vim-repeat',
|
||||||
'google/vim-searchindex',
|
'google/vim-searchindex',
|
||||||
'rbgrouleff/bclose.vim',
|
'rbgrouleff/bclose.vim',
|
||||||
'Pocco81/auto-save.nvim', -- autosave files
|
|
||||||
'windwp/nvim-autopairs', -- auto pair brackets and tags
|
|
||||||
'lewis6991/gitsigns.nvim', -- git integration
|
|
||||||
'windwp/nvim-ts-autotag',
|
|
||||||
'chaoren/vim-wordmotion',
|
'chaoren/vim-wordmotion',
|
||||||
|
{
|
||||||
|
'windwp/nvim-autopairs',
|
||||||
|
desc = "Auto pair brackets and tags",
|
||||||
|
config = function()
|
||||||
|
require("nvim-autopairs").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'windwp/nvim-ts-autotag',
|
||||||
|
config = function()
|
||||||
|
require("nvim-ts-autotag").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
enabled = vim.fn.executable "git" == 1,
|
||||||
|
config = function()
|
||||||
|
require("gitsigns").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
'numToStr/Comment.nvim',
|
'numToStr/Comment.nvim',
|
||||||
|
config = function()
|
||||||
|
require("Comment").setup()
|
||||||
|
end
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'norcalli/nvim-colorizer.lua',
|
'norcalli/nvim-colorizer.lua',
|
||||||
config = function()
|
config = function()
|
||||||
@ -28,10 +49,22 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
build = ':TSUpdate'
|
build = ':TSUpdate',
|
||||||
|
config = function()
|
||||||
|
require("nvim-treesitter.configs").setup({
|
||||||
|
ensure_installed = {"python", "lua", "vim", "html", "rust", "markdown"},
|
||||||
|
auto_install = true,
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'folke/trouble.nvim',
|
'folke/trouble.nvim',
|
||||||
dependencies = { 'kyazdani42/nvim-web-devicons' }
|
dependencies = { 'kyazdani42/nvim-web-devicons' },
|
||||||
|
config = function()
|
||||||
|
require("trouble").setup()
|
||||||
|
end
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,130 @@
|
|||||||
|
local border_opts = {
|
||||||
|
border = "single",
|
||||||
|
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
|
||||||
|
}
|
||||||
|
|
||||||
|
local function has_words_before()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup_cmp()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
completion = {
|
||||||
|
autocomplete = false
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(border_opts),
|
||||||
|
documentation = cmp.config.window.bordered(border_opts),
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp', priority = 1000 },
|
||||||
|
{ name = 'luasnip', priority = 750 },
|
||||||
|
{ name = 'buffer', priority = 500 },
|
||||||
|
{ name = 'path', priority = 250 },
|
||||||
|
}, {
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'path' }
|
||||||
|
}, {
|
||||||
|
{ name = 'cmdline' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup_lspconfig()
|
||||||
|
local nvim_lsp = require("lspconfig")
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
|
||||||
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||||
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||||
|
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||||
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||||
|
-- map buffer local keybindings when the language server attaches
|
||||||
|
local servers = { 'pyright', 'lua_ls', 'rust_analyzer' }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
|
nvim_lsp.clangd.setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
@ -8,13 +135,45 @@ return {
|
|||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
},
|
},
|
||||||
|
config = setup_cmp,
|
||||||
|
keys = {
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'neovim/nvim-lspconfig'
|
'neovim/nvim-lspconfig',
|
||||||
|
config = setup_lspconfig,
|
||||||
|
keys = {
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'L3MON4D3/LuaSnip',
|
'L3MON4D3/LuaSnip',
|
||||||
dependencies = 'hrsh7th/nvim-cmp',
|
dependencies = 'hrsh7th/nvim-cmp',
|
||||||
|
config = function()
|
||||||
|
local ls = require("luasnip")
|
||||||
|
|
||||||
|
vim.g.snips_author = 'thek4n'
|
||||||
|
vim.g.snips_email = 'thek4n@yandex.com'
|
||||||
|
vim.g.snips_github = 'https://github.com/thek4n'
|
||||||
|
|
||||||
|
|
||||||
|
local function jump(val)
|
||||||
|
return function()
|
||||||
|
ls.jump(val)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local map = vim.keymap.set
|
||||||
|
map({'i', 's'}, '<C-n>', jump(1))
|
||||||
|
map({'i', 's'}, '<C-p>', jump(-1))
|
||||||
|
|
||||||
|
|
||||||
|
local luasnip_loaders = require("luasnip.loaders.from_snipmate")
|
||||||
|
|
||||||
|
luasnip_loaders.lazy_load()
|
||||||
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'honza/vim-snippets'
|
'honza/vim-snippets'
|
||||||
|
|||||||
@ -12,5 +12,67 @@ return {
|
|||||||
keys = {
|
keys = {
|
||||||
{ '<Leader>ff', '<cmd>Telescope find_files<CR>' },
|
{ '<Leader>ff', '<cmd>Telescope find_files<CR>' },
|
||||||
{ '<Leader>fg', '<cmd>Telescope live_grep<CR>' },
|
{ '<Leader>fg', '<cmd>Telescope live_grep<CR>' },
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
telescope = require("telescope")
|
||||||
|
|
||||||
|
telescope.load_extension("fzf")
|
||||||
|
|
||||||
|
telescope.setup({
|
||||||
|
defaults = {
|
||||||
|
selection_caret = " ",
|
||||||
|
path_display = { "smart" },
|
||||||
|
file_ignore_patterns = {
|
||||||
|
".git/",
|
||||||
|
"target/",
|
||||||
|
"docs/",
|
||||||
|
"vendor/*",
|
||||||
|
"%.lock",
|
||||||
|
"pycache/*",
|
||||||
|
"%.sqlite3",
|
||||||
|
"%.ipynb",
|
||||||
|
"node_modules/*",
|
||||||
|
"%.svg",
|
||||||
|
"%.otf",
|
||||||
|
"%.ttf",
|
||||||
|
"%.webp",
|
||||||
|
".dart_tool/",
|
||||||
|
".github/",
|
||||||
|
".gradle/",
|
||||||
|
".idea/",
|
||||||
|
".settings/",
|
||||||
|
".vscode/",
|
||||||
|
"pycache/",
|
||||||
|
"build/",
|
||||||
|
"env/",
|
||||||
|
"gradle/",
|
||||||
|
"node_modules/",
|
||||||
|
"%.pdb",
|
||||||
|
"%.dll",
|
||||||
|
"%.class",
|
||||||
|
"%.exe",
|
||||||
|
"%.cache",
|
||||||
|
"%.ico",
|
||||||
|
"%.pdf",
|
||||||
|
"%.dylib",
|
||||||
|
"%.jar",
|
||||||
|
"%.docx",
|
||||||
|
"%.met",
|
||||||
|
"smalljre_*/*",
|
||||||
|
".vale/",
|
||||||
|
"%.burp",
|
||||||
|
"%.mp4",
|
||||||
|
"%.mkv",
|
||||||
|
"%.rar",
|
||||||
|
"%.zip",
|
||||||
|
"%.7z",
|
||||||
|
"%.tar",
|
||||||
|
"%.bz2",
|
||||||
|
"%.epub",
|
||||||
|
"%.flac",
|
||||||
|
"%.tar.gz",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user