migrate some plugins to Lazy

This commit is contained in:
2023-02-11 21:51:58 +08:00
parent 54bf43ffa8
commit c4f262a504
37 changed files with 598 additions and 729 deletions
+4 -7
View File
@@ -6,14 +6,10 @@
* Windows: `~/AppData/Local/nvim/`
* Linux: `~/.config/nvim/`
2. Run `nvim`
3. Restart nvim after Packer Sync process
**Note**: Make sure there is no file `plugin/packer_compiled.lua` before step2.
## Plugins
* [wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim)
* [lewis6991/impatient.nvim](https://github.com/lewis6991/impatient.nvim)
* [folke/lazy.nvim](https://github.com/folke/lazy.nvim)
* [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
* [jiangmiao/auto-pairs](https://github.com/jiangmiao/auto-pairs)
* [lukas-reineke/indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim)
@@ -44,7 +40,7 @@
- [x] LSP
- [x] 调整配置文件缩进
- [x] Packer Plugins 懒加载
- [x] ~~Packer Plugins 懒加载~~
- [x] CMP snip换行后tab数量问题
- [x] CMP command 不区分大小写
- [x] CMP document border
@@ -57,4 +53,5 @@
- [x] Luasnip 功能
- [x] LuaLine
- [x] shift 块后保持选择
- [ ] window resize 快捷键
- [x] window resize 快捷键
- [ ] nvimtree 抢占Lazy窗口焦点
+1 -2
View File
@@ -1,4 +1,3 @@
pcall(require, 'impatient')
require 'configs.options'
require 'configs.keymaps'
require 'configs.plugins.packer'
require 'configs.lazy'
+28
View File
@@ -0,0 +1,28 @@
{
"Comment.nvim": { "branch": "master", "commit": "eab2c83a0207369900e92783f56990808082eac2" },
"LuaSnip": { "branch": "master", "commit": "9bff06b570df29434a88f9c6a9cea3b21ca17208" },
"better-escape.nvim": { "branch": "master", "commit": "6fed33809cde3b416087fc540ad9eb17ec470193" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"friendly-snippets": { "branch": "main", "commit": "80597f3ea824946c87fd29f82b5ed4f24ef473f3" },
"gitsigns.nvim": { "branch": "main", "commit": "f29f0b22fd66c910b892aae3bc18a4872c002738" },
"indent-blankline.nvim": { "branch": "master", "commit": "8299fe7703dfff4b1752aeed271c3b95281a952d" },
"lazy.nvim": { "branch": "main", "commit": "4917222c7e5c924bf7471b72a5e2d3e661530b40" },
"lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7a97a77eee486ae152d2c559a459eda7c8aa12aa" },
"mason.nvim": { "branch": "main", "commit": "47e9f6bc4c5bb3d6453949f07b8280c725ef7490" },
"nvim-autopairs": { "branch": "master", "commit": "45ae3122a4c7744db41298b41f9f5a3f092123e6" },
"nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" },
"nvim-lspconfig": { "branch": "master", "commit": "27e6eb27f31d1ef41427e1008029284c02dc856f" },
"nvim-tree.lua": { "branch": "master", "commit": "b712b82b0ca4eb402ced2d83f8082366989e43e0" },
"nvim-treesitter": { "branch": "master", "commit": "f6df07be122de665fb363476cc3680c90f5bdf05" },
"nvim-web-devicons": { "branch": "master", "commit": "4475fe5ffd32360fb6c351abbfee8d7529a511e6" },
"plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" },
"symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" },
"telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" },
"toggleterm.nvim": { "branch": "main", "commit": "19aad0f41f47affbba1274f05e3c067e6d718e1e" },
"tokyonight.nvim": { "branch": "main", "commit": "a0abe53df53616d13da327636cb0bcac3ea7f5af" }
}
+58 -36
View File
@@ -1,55 +1,77 @@
local opts = {
silent = true
}
local function map(mode, lhs, rhs, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
vim.keymap.set(mode, lhs, rhs, opts)
end
vim.keymap.set('', '<Space>', '<Nop>', opts)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
map("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Use ESC to turn off search highlighting
vim.keymap.set('n', '<Esc>', ':noh<CR>', opts)
map({ "i", "n" }, "<Esc>", "<Cmd>noh<CR><Esc>", { desc = "Escape and clear hlsearch" })
-- Move in insert mode
vim.keymap.set('i', '<C-h>', '<Left>', opts)
vim.keymap.set('i', '<C-j>', '<Down>', opts)
vim.keymap.set('i', '<C-k>', '<Up>', opts)
vim.keymap.set('i', '<C-l>', '<Right>', opts)
map("i", "<C-h>", "<Left>")
map("i", "<C-j>", "<Down>")
map("i", "<C-k>", "<Up>")
map("i", "<C-l>", "<Right>")
-- Moving line
-- == re-indents the line to suit its new position
-- gc reselects the last visual block
-- = re-indents the block
vim.keymap.set('n', '<A-j>', ':m .+1<CR>==', opts)
vim.keymap.set('n', '<A-k>', ':m .-2<CR>==', opts)
vim.keymap.set('i', '<A-j>', '<Esc>:m .+1<CR>==gi', opts)
vim.keymap.set('i', '<A-k>', '<Esc>:m .-2<CR>==gi', opts)
vim.keymap.set('v', '<A-j>', ":m '>+1<CR>gv=gv", opts)
vim.keymap.set('v', '<A-k>', ":m '<-2<CR>gv=gv", opts)
map("n", "<A-j>", "<Cmd>m .+1<CR>==", { desc = "Move down" })
map("n", "<A-k>", "<Cmd>m .-2<CR>==", { desc = "Move up" })
map("i", "<A-j>", "<Esc><Cmd>m .+1<CR>==gi", { desc = "Move down" })
map("i", "<A-k>", "<Esc><Cmd>m .-2<CR>==gi", { desc = "Move up" })
-- The colon(:) bellow cannot be replaced by <Cmd>
map("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move down" })
map("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move up" })
-- Keep selecting visual block
vim.keymap.set('v', '<', '<gv', opts)
vim.keymap.set('v', '>', '>gv', opts)
map("v", "<", "<gv")
map("v", ">", ">gv")
-- Navigating window
vim.keymap.set('n', '<C-h>', '<C-w>h', opts)
vim.keymap.set('n', '<C-j>', '<C-w>j', opts)
vim.keymap.set('n', '<C-k>', '<C-w>k', opts)
vim.keymap.set('n', '<C-l>', '<C-w>l', opts)
-- Add undo break-points
map("i", ",", ",<C-g>u")
map("i", ".", ".<C-g>u")
map("i", ";", ";<C-g>u")
-- Keymaps for NvimTree
vim.keymap.set('n', '<C-n>', ':NvimTreeFindFileToggle <CR>', opts)
vim.keymap.set('n', '<leader>a', ':NvimTreeFocus <CR>', opts)
-- save file
map({ "i", "v", "n", "s" }, "<C-s>", "<Cmd>w<CR><Esc>", { desc = "Save file" })
map({ "i", "v", "n", "s" }, "<Leader>fs", "<Cmd>w<CR><Esc>", { desc = "Save file" })
-- Keymaps for Telescope
vim.keymap.set('n', '<leader>ff', ':Telescope find_files <CR>', opts)
vim.keymap.set('n', '<leader>fg', ':Telescope live_grep <CR>', opts)
vim.keymap.set('n', '<leader>fb', ':Telescope buffers <CR>', opts)
vim.keymap.set('n', '<leader>fh', ':Telescope help_tags <CR>', opts)
-- Move to window using the <ctrl> hjkl keys
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })
-- Resize window using <ctrl> arrow keys
map("n", "<C-Up>", "<Cmd>resize +2<CR>", { desc = "Increase window height" })
map("n", "<C-Down>", "<Cmd>resize -2<CR>", { desc = "Decrease window height" })
map("n", "<C-Left>", "<Cmd>vertical resize -2<CR>", { desc = "Decrease window width" })
map("n", "<C-Right>", "<Cmd>vertical resize +2<CR>", { desc = "Increase window width" })
-- split/delete windows
map("n", "<Leader>ww", "<C-W>p", { desc = "Other window" })
map("n", "<Leader>wd", "<C-W>c", { desc = "Delete window" })
map("n", "<Leader>w|", "<C-W>s", { desc = "Split window below" })
map("n", "<Leader>w-", "<C-W>v", { desc = "Split window right" })
map("n", "<Leader>|", "<C-W>s", { desc = "Split window below" })
map("n", "<Leader>-", "<C-W>v", { desc = "Split window right" })
-- quit
map("n", "<Leader>qq", "<Cmd>qa<CR>", { desc = "Quit all" })
-- Keymaps for LSP
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.keymap.set('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
map("n", "<space>e", "<Cmd>lua vim.diagnostic.open_float()<CR>")
map("n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
map("n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>")
map("n", "<space>q", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
+24
View File
@@ -0,0 +1,24 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system(
{"git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release
lazypath})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")
-- {
-- "jose-elias-alvarez/null-ls.nvim",
-- config = function()
-- require("configs.plugins.null_ls")
-- end
-- },
-- -- UI Plugins
-- {
-- "akinsho/bufferline.nvim",
-- tag = "*",
-- requires = "nvim-tree/nvim-web-devicons",
-- config = function()
-- require("configs.plugins.bufferline")
-- end
-- }}
+17 -14
View File
@@ -1,31 +1,34 @@
vim.opt.clipboard = 'unnamedplus'
vim.opt.number = true
vim.opt.cursorline = true
vim.opt.numberwidth = 2
vim.opt.wrap = false
vim.opt.confirm = true -- Confirm to save changes before exiting modified buffer
vim.opt.cursorline = true -- Enable highlighting of the current line
vim.opt.fileencoding = 'utf-8'
vim.opt.mouse = 'a'
vim.opt.updatetime = 250
vim.opt.list = true
vim.opt.mouse = 'a' -- Enable mouse mode
vim.opt.number = true
vim.opt.numberwidth = 2
vim.opt.showmode = false -- Dont show mode since we have a statusline
vim.opt.timeoutlen = 400
vim.opt.undofile = true
vim.opt.updatetime = 250
vim.opt.wrap = false
vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.pumheight = 13
vim.opt.smartcase = true
vim.opt.wildignorecase = true
vim.opt.wildmenu = false
vim.opt.smartindent = true
vim.opt.autoindent = true
vim.opt.smarttab = true
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.smartindent = true
vim.opt.smarttab = true
vim.opt.softtabstop = 4
vim.opt.splitbelow = true -- Put new windows below current
vim.opt.splitright = true -- Put new windows right of current
vim.opt.tabstop = 4
vim.opt.termguicolors = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.completeopt = 'menu,menuone,noinsert'
vim.opt.shortmess = 'I'
-5
View File
@@ -1,5 +0,0 @@
local autopairs = require('nvim-autopairs')
autopairs.setup({
fast_wrap = {},
})
-5
View File
@@ -1,5 +0,0 @@
local escape = require('better_escape')
escape.setup({
mapping = { 'jk' },
})
-18
View File
@@ -1,18 +0,0 @@
local bufferline = require('bufferline')
local opts = {
noremap = true,
silent = true
}
vim.api.nvim_set_keymap('n', 'gb', ':BufferLinePick<CR>', opts)
vim.api.nvim_set_keymap('n', '<S-l>', ':BufferLineCycleNext<CR>', opts)
vim.api.nvim_set_keymap('n', '<S-h>', ':BufferLineCyclePrev<CR>', opts)
bufferline.setup({
options = {
offsets = {
{ filetype = 'NvimTree', text = 'File Explorer', text_align = 'center' },
},
}
})
-152
View File
@@ -1,152 +0,0 @@
local cmp = require('cmp')
local luasnip = require('luasnip')
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
require("luasnip.loaders.from_vscode").lazy_load()
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
vim.cmd [[highlight CmpItemAbbrDeprecated gui=strikethrough]]
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
luasnip.lsp_expand(args.body)
-- 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.
end
},
formatting = {
fields = { 'kind', 'abbr', 'menu' },
format = function(entry, vim_item)
vim_item.abbr = string.format('%s', vim_item.abbr)
vim_item.kind = string.format('%s', kind_icons[vim_item.kind])
vim_item.menu = ({
nvim_lsp = '[LSP]',
luasnip = '[Snippet]',
buffer = '[BUF]',
path = '[Path]'
})[entry.source.name]
return vim_item
end
},
mapping = {
['<C-k>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({
-- Select but noinsert
behavior = cmp.SelectBehavior.Select
})
else
fallback()
end
end, { 'i', 'c', 's' }),
['<C-j>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({
behavior = cmp.SelectBehavior.Select
})
else
fallback()
end
end, { 'i', 'c', 's' }),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), -- d
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close()
}),
['<CR>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm()
else
fallback()
end
end, { 'i', 's' }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({
select = true
})
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 'c', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' })
},
completion = {
-- Highlight first item
completeopt = 'menu,menuone,noinsert'
},
window = {
documentation = {
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
}
},
experimental = {
-- ghost_text = true
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'cmdline' },
}
})
cmp.setup.cmdline(':', {
sources = { {
name = 'cmdline'
} }
})
cmp.setup.cmdline('/', {
sources = { {
name = 'buffer'
} }
})
-3
View File
@@ -1,3 +0,0 @@
local comment = require('Comment')
comment.setup()
-3
View File
@@ -1,3 +0,0 @@
local gitsigns = require('gitsigns')
gitsigns.setup()
-15
View File
@@ -1,15 +0,0 @@
local indent_blankline = require('indent_blankline')
indent_blankline.setup({
show_current_context = true,
show_current_context_start = true,
filetype_exclude = {
'lspinfo',
'packer',
'checkhealth',
'help',
'man',
'NvimTree',
}
})
-62
View File
@@ -1,62 +0,0 @@
local lsp_installer = require('nvim-lsp-installer')
lsp_installer.setup({
ensure_installed = { 'sumneko_lua', 'jdtls' },
automatic_installation = true,
ui = {
icons = {
server_installed = "✓",
server_pending = "➜",
server_uninstalled = "✗"
}
}
})
local lspconfig = require('lspconfig')
-- 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 opts = {
noremap = true,
silent = true,
buffer = bufnr,
}
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.keymap.set('n', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.keymap.set('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.keymap.set('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.keymap.set('n', '<space>wl',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.keymap.set('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.keymap.set('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.keymap.set('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.keymap.set('n', '<space>f', '<cmd>lua vim.lsp.buf.format {async = true}()<CR>', opts)
end
lspconfig.sumneko_lua.setup({
on_attach = on_attach,
settings = require('configs.plugins.lsp_settings.sumneko_lua'),
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
})
lspconfig.jdtls.setup({
on_attach = on_attach,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
})
lspconfig.jedi_language_server.setup({
on_attach = on_attach,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
})
@@ -1,12 +0,0 @@
return {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.stdpath('config') .. '/lua'] = true,
},
},
}
}
-40
View File
@@ -1,40 +0,0 @@
local lualine = require('lualine')
local lsp_status = function()
if next(vim.lsp.buf_get_clients()) ~= nil then
return '' .. '' .. ' LSP'
else
return ''
end
end
lualine.setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
globalstatus = true,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { lsp_status, 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = { 'nvim-tree', 'symbols-outline', 'toggleterm' },
}
-12
View File
@@ -1,12 +0,0 @@
local mason = require("mason")
mason.setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗"
}
}
})
-53
View File
@@ -1,53 +0,0 @@
local mason_lsp = require("mason-lspconfig")
local lspconfig = require('lspconfig')
mason_lsp.setup({
ensure_installed = { "sumneko_lua", "jdtls", "omnisharp" },
})
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
vim.keymap.set("n", "<space>f", function() vim.lsp.buf.format { async = true } end, bufopts)
end
mason_lsp.setup_handlers({
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn"t have
-- a dedicated handler.
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({
on_attach = on_attach,
})
end,
-- Next, you can provide a dedicated handler for specific servers.
-- For example, a handler override for the `rust_analyzer`:
["sumneko_lua"] = function()
lspconfig.sumneko_lua.setup({
on_attach = on_attach,
settings = require('configs.plugins.lsp_settings.sumneko_lua'),
-- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
})
end
-- ["rust_analyzer"] = function ()
-- require("rust-tools").setup {}
-- end
})
-8
View File
@@ -1,8 +0,0 @@
local null_ls = require('null-ls')
null_ls.setup({
sources = {
-- null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.black,
}
})
-27
View File
@@ -1,27 +0,0 @@
local nvimtree = require("nvim-tree")
nvimtree.setup({
-- open_on_tab = true,
tab = {
sync = {
open = true,
}
},
diagnostics = {
enable = true,
show_on_dirs = false,
},
renderer = {
indent_markers = {
enable = true,
},
group_empty = true,
}
})
local function open_nvim_tree()
-- open the tree
require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
-187
View File
@@ -1,187 +0,0 @@
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
return require("packer").startup({
function(use)
use "wbthomason/packer.nvim"
-- My plugins here
use { "lewis6991/impatient.nvim" }
use {
"nvim-treesitter/nvim-treesitter",
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.plugins.treesitter")
end
}
use {
"windwp/nvim-autopairs", -- Can"t lazyloaded because cmp-related
config = function()
require("configs.plugins.autopairs")
end
}
use {
"lukas-reineke/indent-blankline.nvim",
event = { "BufRead" },
config = function()
require("configs.plugins.indent_blankline")
end
}
use {
"numToStr/Comment.nvim",
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.plugins.comment")
end
}
use {
"lewis6991/gitsigns.nvim",
event = { "BufRead", "BufNewFile" },
config = function()
require("configs.plugins.gitsigns")
end
-- tag = "release" -- To use the latest release
}
use {
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("configs.plugins.better_escape")
end
}
-- CMP plugins
use {
"hrsh7th/nvim-cmp",
config = function()
require("configs.plugins.cmp")
end
}
use { "hrsh7th/cmp-nvim-lsp" }
use { "hrsh7th/cmp-buffer" }
use { "hrsh7th/cmp-path" }
use { "hrsh7th/cmp-cmdline" }
use { "saadparwaiz1/cmp_luasnip" } -- Snippet compleetions
-- Snippets
use { "L3MON4D3/LuaSnip" } -- Snippet engine
use { "rafamadriz/friendly-snippets" } -- Snippets collection
-- LSP
use {
"williamboman/mason.nvim",
requires = { "neovim/nvim-lspconfig" },
config = function()
require("configs.plugins.mason")
end
}
use {
"williamboman/mason-lspconfig.nvim",
config = function()
require("configs.plugins.mason_lspconfig")
end
}
use { "jose-elias-alvarez/null-ls.nvim",
config = function()
require("configs.plugins.null_ls")
end
}
-- UI Plugins
use { "nvim-tree/nvim-web-devicons" }
use {
"nvim-tree/nvim-tree.lua",
requires = { "nvim-tree/nvim-web-devicons" -- optional, for file icon
},
config = function()
require("configs.plugins.nvimtree")
end
}
use {
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
requires = { { "nvim-lua/plenary.nvim" } }
}
use {
"akinsho/bufferline.nvim",
tag = "*",
requires = "nvim-tree/nvim-web-devicons",
config = function()
require("configs.plugins.bufferline")
end
}
use {
"nvim-lualine/lualine.nvim",
requires = { "kyazdani42/nvim-web-devicons" },
config = function()
require("configs.plugins.lualine")
end,
opt = false
}
use { "simrat39/symbols-outline.nvim",
config = function()
vim.keymap.set("n", "<leader>l", ":SymbolsOutline<CR>", { silent = true })
end,
}
use {
"akinsho/toggleterm.nvim",
config = function()
require("configs.plugins.toggleterm")
end
}
-- Themes
use {
"catppuccin/nvim",
as = "catppuccin",
config = function()
vim.g.catppuccin_flavour = "mocha" -- latte, frappe, macchiato, mocha
local catppuccin = require("catppuccin")
catppuccin.setup()
vim.cmd [[colorscheme catppuccin]]
end
}
use {
"folke/tokyonight.nvim",
opt = true,
config = function()
vim.g.tokyonight_style = "night"
vim.cmd [[colorscheme tokyonight]]
end
}
use({
"rose-pine/neovim",
opt = true,
as = "rose-pine",
tag = "v1.*",
config = function()
require("rose-pine").setup({
---@usage "main"|"moon"
dark_variant = "main",
})
-- vim.cmd("colorscheme rose-pine")
end
})
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require("packer").sync()
end
end,
config = {
display = {
open_fn = require('packer.util').float,
}
}
})
-62
View File
@@ -1,62 +0,0 @@
local toggleterm = require("toggleterm")
local shell = vim.o.shell
if vim.loop.os_uname().sysname == 'Windows_NT' then
shell = 'powershell'
end
toggleterm.setup({
-- size can be a number or function which is passed the current terminal
-- size = 20 | function(term)
-- if term.direction == "horizontal" then
-- return 15
-- elseif term.direction == "vertical" then
-- return vim.o.columns * 0.4
-- end
-- end,
open_mapping = [[<c-\>]],
-- on_open = fun(t: Terminal), -- function to run when the terminal opens
-- on_close = fun(t: Terminal), -- function to run when the terminal closes
-- on_stdout = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stdout
-- on_stderr = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stderr
-- on_exit = fun(t: Terminal, job: number, exit_code: number, name: string) -- function to run when terminal process exits
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
-- highlights = {
-- -- highlights which map to a highlight group name and a table of it's values
-- -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split
-- Normal = {
-- guibg = <VALUE-HERE>,
-- },
-- NormalFloat = {
-- link = 'Normal'
-- },
-- FloatBorder = {
-- guifg = <VALUE-HERE>,
-- guibg = <VALUE-HERE>,
-- },
-- },
shade_terminals = true,
-- shading_factor = '<number>', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
persist_size = true,
-- direction = 'vertical' | 'horizontal' | 'tab' | 'float',
direction = 'float',
close_on_exit = true, -- close the terminal window when the process exits
shell = shell, -- change the default shell
-- This field is only relevant if direction is set to 'float'
float_opts = {
-- The border key is *almost* the same as 'nvim_open_win'
-- see :h nvim_open_win for details on borders however
-- the 'curved' border is a custom border type
-- not natively supported but implemented in this plugin.
-- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
border = 'single',
-- width = <value>,
-- height = <value>,
winblend = 3,
}
})
-6
View File
@@ -1,6 +0,0 @@
require('nvim-treesitter.configs').setup({
ensure_installed = { 'c', 'c_sharp', 'cpp', 'go', 'help', 'java', 'json', 'lua', 'python', 'vim' },
highlight = {
enable = true,
}
})
+7
View File
@@ -0,0 +1,7 @@
return {{
"windwp/nvim-autopairs",
event = {"InsertEnter"},
opts = {
fast_wrap = {}
}
}}
+8
View File
@@ -0,0 +1,8 @@
return {
"max397574/better-escape.nvim",
event = "InsertEnter",
opts = {
mapping = {"jk", "jj"}
}
}
+183
View File
@@ -0,0 +1,183 @@
return { {
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
event = { "InsertEnter", --
"CmdlineEnter" -- for enable cmp when typing command
},
dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline",
"saadparwaiz1/cmp_luasnip", "windwp/nvim-autopairs", {
"L3MON4D3/LuaSnip",
dependencies = {
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end
}
} },
opts = function()
local cmp = require("cmp")
local luasnip = require('luasnip')
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
local has_words_before = function()
unpack = unpack or table.unpack
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
return {
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
luasnip.lsp_expand(args.body)
-- 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.
end
},
formatting = {
fields = { 'kind', 'abbr', 'menu' },
format = function(entry, vim_item)
vim_item.abbr = string.format('%s', vim_item.abbr)
vim_item.kind = string.format('%s', kind_icons[vim_item.kind])
vim_item.menu = ({
nvim_lsp = '[LSP]',
luasnip = '[Snippet]',
buffer = '[BUF]',
path = '[Path]',
})[entry.source.name]
return vim_item
end
},
mapping = {
['<C-k>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({
-- Select but noinsert
behavior = cmp.SelectBehavior.Select
})
else
fallback()
end
end, { 'i', 'c', 's' }),
['<C-j>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({
behavior = cmp.SelectBehavior.Select
})
else
fallback()
end
end, { 'i', 'c', 's' }),
['<C-b>'] = cmp.mapping.scroll_docs( -4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), -- d
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close()
}),
['<CR>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm()
else
fallback()
end
end, { 'i', 's' }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({
select = true
})
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 'c', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable( -1) then
luasnip.jump( -1)
else
fallback()
end
end, { 'i', 's' })
},
completion = {
-- Highlight first item
completeopt = 'menu,menuone,noinsert'
},
window = {
documentation = {
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }
}
},
experimental = {
ghost_text = {
hl_group = "LspCodeLens"
}
},
sources = { {
name = 'nvim_lsp',
keyword_length = 1,
}, {
name = 'luasnip'
}, {
name = 'buffer'
}, {
name = 'path'
} }
}
end,
config = function(_, opts)
vim.cmd [[highlight CmpItemAbbrDeprecated gui=strikethrough]]
local cmp = require("cmp")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) -- Add parentheses after selecting function or method item
cmp.setup(opts)
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end
} }
+5
View File
@@ -0,0 +1,5 @@
return {
"numToStr/Comment.nvim",
event = {"BufRead", "BufNewFile"},
config = true
}
+6
View File
@@ -0,0 +1,6 @@
return {
"lewis6991/gitsigns.nvim",
event = {"BufRead", "BufNewFile"},
config = true
-- tag = "release" -- To use the latest release
}
+10
View File
@@ -0,0 +1,10 @@
return {{
"lukas-reineke/indent-blankline.nvim",
event = {"BufRead"},
opts = {
show_current_context = true,
show_current_context_start = true,
filetype_exclude = {'lspinfo', 'lazy', 'checkhealth', 'help', 'man', 'NvimTree'}
}
}}
+73
View File
@@ -0,0 +1,73 @@
return {{
"williamboman/mason.nvim",
config = true
}, {
"williamboman/mason-lspconfig.nvim",
event = {"BufReadPre", "BufNewFile"},
opts = {
ensure_installed = {"sumneko_lua", "jdtls", "omnisharp"}
},
config = function(_, opts)
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = {
noremap = true,
silent = true,
buffer = bufnr
}
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format {
async = true
}
end, bufopts)
end
local lspconfig = require('lspconfig')
require("mason-lspconfig").setup(opts)
require("mason-lspconfig").setup_handlers {
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({
on_attach = on_attach
})
end,
["sumneko_lua"] = function()
lspconfig.sumneko_lua.setup({
on_attach = on_attach,
settings = {
Lua = {
diagnostics = {
globals = {"vim"}
},
workspace = {
library = {
[vim.fn.stdpath('config') .. '/lua'] = true
}
}
}
}
-- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()),
})
end
}
end,
dependencies = {"neovim/nvim-lspconfig"}
}}
+60
View File
@@ -0,0 +1,60 @@
local lsp_status = function()
if next(vim.lsp.buf_get_clients()) ~= nil then
return "" .. "" .. " LSP"
else
return ""
end
end
return {{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = {"nvim-tree/nvim-web-devicons"},
opts = {
options = {
icons_enabled = true,
theme = "auto",
component_separators = {
left = "",
right = ""
},
section_separators = {
left = "",
right = ""
},
disabled_filetypes = {"lazy"},
always_divide_middle = true,
globalstatus = true
},
sections = {
lualine_a = {"mode"},
lualine_b = {"branch", "diff", "diagnostics"},
lualine_c = {{
"filetype",
icon_only = true,
separator = "",
padding = {
left = 1,
right = 0
},
icon = {
align = "right"
}
}, "filename"},
lualine_x = {"searchcount", lsp_status, "encoding", "fileformat", "filetype"},
lualine_y = {"progress"},
lualine_z = {"location"}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {"filename"},
lualine_x = {"location"},
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = {"nvim-tree", "symbols-outline", "toggleterm"}
}
}}
+44
View File
@@ -0,0 +1,44 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = {"nvim-tree/nvim-web-devicons" -- optional, for file icon
},
lazy = false,
opts = {
-- open_on_tab = true,
tab = {
sync = {
open = true
}
},
diagnostics = {
enable = true,
show_on_dirs = false
},
renderer = {
indent_markers = {
enable = true
},
group_empty = true
}
},
keys = {{
'<C-n>',
'<Cmd>NvimTreeFindFileToggle <CR>',
desc = "Nvimtree Toggle"
}, {
'<Leader>a',
'<Cmd>NvimTreeFocus <CR>',
desc = "Nvimtree Focus"
}},
config = function()
require("nvim-tree").setup(opts)
local function open_nvim_tree()
-- open the tree
require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({"VimEnter"}, {
callback = open_nvim_tree
})
end
}
+9
View File
@@ -0,0 +1,9 @@
return {
"simrat39/symbols-outline.nvim",
cmd = "SymbolsOutline",
keys = {{
"<Leader>cs",
"<Cmd>SymbolsOutline<CR>",
desc = "Symbols Outline"
}}
}
+22
View File
@@ -0,0 +1,22 @@
return {{
"nvim-telescope/telescope.nvim",
dependencies = {"nvim-lua/plenary.nvim"},
cmd = "Telescope",
keys = {{
'<Leader>ff',
'<Cmd>Telescope find_files <CR>',
desc = "Find File"
}, {
'<Leader>fg',
'<Cmd>Telescope live_grep <CR>',
desc = "Find Grep"
}, {
'<Leader>fb',
'<Cmd>Telescope buffers <CR>',
desc = "Find Buffer"
}, {
'<Leader>fh',
'<Cmd>Telescope help_tags <CR>',
desc = "Find Help"
}}
}}
+9
View File
@@ -0,0 +1,9 @@
return {{
"folke/tokyonight.nvim",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
-- load the colorscheme here
vim.cmd([[colorscheme tokyonight]])
end
}}
+14
View File
@@ -0,0 +1,14 @@
local shell = vim.o.shell
if vim.loop.os_uname().sysname == 'Windows_NT' then
shell = 'powershell'
end
return { {
"akinsho/toggleterm.nvim",
cmd = "ToggleTerm",
keys = { { "<C-\\>", "<Cmd>ToggleTerm<CR>", desc = "ToggleTerm" } },
opts = {
open_mapping = [[<C-\>]],
shell = shell
},
} }
+16
View File
@@ -0,0 +1,16 @@
return {
"nvim-treesitter/nvim-treesitter",
version = false,
build = ":TSUpdate",
event = {"BufReadPost", "BufNewFile"},
opts = {
ensure_installed = {"c", "c_sharp", "cpp", "go", "help", "java", "json", "lua", "python", "vim"},
highlight = {
enable = true
}
},
---@param opts TSConfig
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end
}