Compare commits

..
28 Commits
Author SHA1 Message Date
c-my ab5e030fe5 nvim-cmp: fix kind icons for new nerd-fonts 2023-05-19 23:10:51 +08:00
c-my 416ac23572 lualine: add lazy extension 2023-04-27 16:32:48 +08:00
c-my 677d3fc48b options: add some new options 2023-04-26 20:27:13 +08:00
c-my 8f5a578c93 autocmd: remove telescope autocmd 2023-04-26 20:26:50 +08:00
c-my 4d3e820499 reformat 2023-04-26 20:26:16 +08:00
c-my cfef04afb7 texlab: add short keys in insert mode for Build and ForwardSearch 2023-04-26 20:25:48 +08:00
c-my e02d6786ab keymaps: better up&down; new file 2023-04-26 15:35:18 +08:00
c-my 9cc3ec057d telescope: work around its fold issue && use "0.1.x" branch 2023-04-26 15:34:30 +08:00
c-my a4e4c78012 colortheme: change set method
we install 2 themes in themes.lua,
and then set colorscheme in init.lua
2023-04-26 15:33:25 +08:00
c-my 91aa6f61d5 telescope: add some configs 2023-04-26 00:06:55 +08:00
c-my 8ed9f98fcc lsp: use new config structure 2023-04-26 00:05:45 +08:00
c-my 45b2a50dcf nvimtree: update config 2023-04-26 00:05:05 +08:00
c-my 92ff84e952 keymap: fix map leader in insert mode 2023-04-26 00:03:37 +08:00
c-my 70c2504886 update packages 2023-04-25 23:58:16 +08:00
c-my a07f7cc5f7 format with stylua 2023-02-14 00:53:53 +08:00
c-my 90d887185d format with stylua 2023-02-13 23:37:06 +08:00
c-my af22747bd7 null-ls: add stylua and its config for neovim dotfiles 2023-02-13 23:36:39 +08:00
c-my 61b1e9aae8 fix: lazy load null-ls 2023-02-13 19:32:41 +08:00
c-my 7fc9b3b9e5 null-ls: fix setup 2023-02-13 19:00:02 +08:00
c-my f7f2b4bcc9 null-ls: add black 2023-02-13 18:52:30 +08:00
c-my 3d730fb28d lsp: change some keybiddings 2023-02-13 16:13:08 +08:00
c-my 0997b7a5d2 tree-sitter: add yaml in ensure_installed 2023-02-13 14:41:19 +08:00
c-my 1703edcb03 nvimtree: open without focus 2023-02-13 14:39:49 +08:00
c-my a59a9b384b fix: disable open nvimtree on startup 2023-02-13 13:54:36 +08:00
c-my f556574da0 lsp: update sumneko_lua to lua_ls 2023-02-12 22:55:35 +08:00
c-my b7b98a0985 add some autocmds 2023-02-11 23:06:19 +08:00
c-my 2e8338395a add pyright 2023-02-11 22:33:36 +08:00
c-my c4f262a504 migrate some plugins to Lazy 2023-02-11 21:51:58 +08:00
43 changed files with 835 additions and 745 deletions

No files matched your search

+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窗口焦点
+6 -4
View File
@@ -1,4 +1,6 @@
pcall(require, 'impatient')
require 'configs.options'
require 'configs.keymaps'
require 'configs.plugins.packer'
require("configs.options")
require("configs.keymaps")
require("configs.autocmds")
require("configs.lazy")
vim.cmd.colorscheme("catppuccin")
+30
View File
@@ -0,0 +1,30 @@
{
"Comment.nvim": { "branch": "master", "commit": "a89339ffbee677ab0521a483b6dac7e2e67c907e" },
"LuaSnip": { "branch": "master", "commit": "e77fa9ad0b1f4fc6cddf54e51047e17e90c7d7ed" },
"better-escape.nvim": { "branch": "master", "commit": "426d29708064d5b1bfbb040424651c92af1f3f64" },
"catppuccin": { "branch": "main", "commit": "dd176757cc745f71bd54c472a9f58d5f8a54661d" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "5af1bb7d722ef8a96658f01d6eb219c4cf746b32" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"friendly-snippets": { "branch": "main", "commit": "631f79e346b0b3203d2ce3eae619ca8d612e5463" },
"gitsigns.nvim": { "branch": "main", "commit": "7dfe4be94b4f84a9931098f0f0f618d055e50bd5" },
"indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" },
"lazy.nvim": { "branch": "main", "commit": "903f0fe542fc35b74f3c09494f9c175346dfa76d" },
"lualine.nvim": { "branch": "master", "commit": "84ffb80e452d95e2c46fa29a98ea11a240f7843e" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "a430dd7696f9cf9423ac3d902a049fa315d8d296" },
"mason.nvim": { "branch": "main", "commit": "253961cfe9b0a63b2524088be294acd7522366e5" },
"null-ls.nvim": { "branch": "main", "commit": "33b853a3933eed3137cd055aac4e539e69832ad0" },
"nvim-autopairs": { "branch": "master", "commit": "7566a86f44bb72ba2b1a609f528a27d93241502d" },
"nvim-cmp": { "branch": "main", "commit": "11102d3db12c7f8b35265ad0e17a21511e5b1e68" },
"nvim-lspconfig": { "branch": "master", "commit": "427378a03ffc1e1bc023275583a49b1993e524d0" },
"nvim-tree.lua": { "branch": "master", "commit": "bb375fb20327c49920c41d2b51c1ce2f4fe7deb3" },
"nvim-treesitter": { "branch": "master", "commit": "08e8b2c08bfdcd20e4561620ca0ccda0bb2e050a" },
"nvim-web-devicons": { "branch": "master", "commit": "4ec26d67d419c12a4abaea02f1b6c57b40c08d7e" },
"plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" },
"symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" },
"telescope.nvim": { "branch": "0.1.x", "commit": "9de317bdea2bc393074651179c4fc7f93e9b2d56" },
"toggleterm.nvim": { "branch": "main", "commit": "68fdf851c2b7901a7065ff129b77d3483419ddce" },
"tokyonight.nvim": { "branch": "main", "commit": "ab0ac67f4f32f44c3480f4b81ed90e11cb4f3763" }
}
+24
View File
@@ -0,0 +1,24 @@
-- close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("close_with_q", { clear = true }),
pattern = {
"qf", -- quickfix window
"help",
"man",
"notify",
"lspinfo",
"spectre_panel",
"startuptime",
"tsplayground",
"PlenaryTestPopup",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<Cmd>close<CR>", { buffer = event.buf, silent = true, desc = "Close Buffer" })
end,
})
-- Restore terminal cursor shape
vim.api.nvim_create_autocmd(
"VimLeave",
{ pattern = "*", command = "set guicursor=a:ver20-blinkwait300-blinkon200-blinkoff150" }
)
+58 -39
View File
@@ -1,55 +1,74 @@
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>")
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" })
-- better up/down
map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- 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({ "v", "n", "s" }, "<Leader>fs", "<Cmd>w<CR><Esc>", { desc = "Save file" })
-- New file
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
-- 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" })
-- 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)
-- 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" })
-- 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)
-- 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" })
-- Lazy
map("n", "<leader>l", "<Cmd>:Lazy<cr>", { desc = "Lazy" })
+23
View File
@@ -0,0 +1,23 @@
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")
-- -- UI Plugins
-- {
-- "akinsho/bufferline.nvim",
-- tag = "*",
-- requires = "nvim-tree/nvim-web-devicons",
-- config = function()
-- require("configs.plugins.bufferline")
-- end
-- }}
+44 -25
View File
@@ -1,36 +1,55 @@
vim.opt.clipboard = 'unnamedplus'
vim.opt.number = true
vim.opt.cursorline = true
vim.opt.clipboard = "unnamedplus"
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.foldmethod = "expr"
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.list = true
vim.opt.mouse = "a" -- Enable mouse mode
vim.opt.number = true -- Print line number
vim.opt.numberwidth = 2
vim.opt.wrap = false
vim.opt.fileencoding = 'utf-8'
vim.opt.mouse = 'a'
vim.opt.updatetime = 250
vim.opt.showmode = false -- Dont show mode since we have a statusline
vim.opt.scrolloff = 4
vim.opt.sidescrolloff = 5
vim.opt.termguicolors = true
vim.opt.timeoutlen = 400
vim.opt.undofile = true
vim.opt.updatetime = 250 -- Save swap file and trigger CursorHold
vim.opt.wrap = false
vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.pumheight = 13
vim.opt.smartcase = true -- Dont ignore case when there is capitals
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.splitbelow = true -- Put new windows below current
vim.opt.splitright = true -- Put new windows right of current
vim.opt.termguicolors = true
vim.opt.splitbelow = true
vim.opt.splitright = true
-- Tab and Shift
vim.opt.autoindent = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.smartindent = true
vim.opt.smarttab = true
vim.opt.softtabstop = 4
vim.opt.tabstop = 4 -- Spaces in tab
vim.opt.completeopt = 'menu,menuone,noinsert'
vim.opt.shortmess = 'I'
vim.api.nvim_create_autocmd(
"VimLeave",
{ pattern = "*", command = "set guicursor=a:ver20-blinkwait300-blinkon200-blinkoff150" }
)
vim.opt.completeopt = "menu,menuone,noinsert"
vim.opt.shortmess = "I"
vim.opt.splitkeep = "screen"
-- Fold
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldenable = false
vim.opt.foldlevel = 100
vim.opt.fillchars = {
fold = " ",
}
function _G.my_foldtext()
local line = vim.fn.getline(vim.v.foldstart)
-- local line_count = vim.v.foldend - vim.v.foldstart + 1
return line .. " "
end
vim.opt.foldtext = "v:lua.my_foldtext()"
-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,
}
})
+9
View File
@@ -0,0 +1,9 @@
return {
{
"windwp/nvim-autopairs",
event = { "InsertEnter" },
opts = {
fast_wrap = {},
},
},
}
+7
View File
@@ -0,0 +1,7 @@
return {
"max397574/better-escape.nvim",
event = "InsertEnter",
opts = {
mapping = { "jk", "jj" },
},
}
+199
View File
@@ -0,0 +1,199 @@
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
}
+12
View File
@@ -0,0 +1,12 @@
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" },
},
},
}
+94
View File
@@ -0,0 +1,94 @@
return {
{
"williamboman/mason.nvim",
config = true,
},
{
"williamboman/mason-lspconfig.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
ensure_installed = { "jdtls", "omnisharp", "pyright", "lua_ls" },
},
config = function(_, opts)
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- stylua: ignore start
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Goto Declaration", buffer = ev.buf })
vim.keymap.set("n", "gd", "<Cmd>Telescope lsp_definitions theme=get_cursor<CR>", { desc = "Goto Definition", buffer = ev.buf })
vim.keymap.set("n", "gr", "<Cmd>Telescope lsp_references theme=get_cursor<CR>", { desc = "Goto References", buffer = ev.buf })
vim.keymap.set("n", "gi", "<Cmd>Telescope lsp_implementation theme=get_cursor<CR>", { desc = "Goto Implementation", buffer = ev.buf })
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover", buffer = ev.buf })
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, { desc = "Signature Help", buffer = ev.buf })
vim.keymap.set("n", "<Leader>wa", vim.lsp.buf.add_workspace_folder, { buffer = ev.buf })
vim.keymap.set("n", "<Leader>wr", vim.lsp.buf.remove_workspace_folder, { buffer = ev.buf })
vim.keymap.set("n", "<Leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, { buffer = ev.buf })
vim.keymap.set("n", "<Leader>D", "<Cmd>Telescope lsp_type_definitions theme=get_cursor<CR>", { buffer = ev.buf })
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, { buffer = ev.buf })
vim.keymap.set({ "n", "v" }, "<Leader>ca", vim.lsp.buf.code_action, { desc = "Code Action", buffer = ev.buf })
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, { desc = "Format Document", buffer = ev.buf })
-- stylua ignore end
end,
})
local on_attach = function(client, bufnr)
-- Avoiding LSP formatting conflicts
local null_ls_table = { pyright = true, lua_ls = true }
if null_ls_table[client.name] then
client.server_capabilities.documentFormattingProvider = false -- 0.8 and later
end
end
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
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,
capabilities = capabilities,
})
end,
["pyright"] = function()
local pyright_config = require("plugins.lsp.pyright")
lspconfig.pyright.setup({
capabilities = capabilities,
on_attach = pyright_config.on_attach,
})
end,
["lua_ls"] = function()
local lua_config = require("plugins.lsp.lua")
lspconfig.lua_ls.setup({
on_attach = lua_config.on_attach,
capabilities = capabilities,
settings = lua_config.settings,
})
end,
["texlab"] = function()
local texlab_config = require("plugins.lsp.texlab")
lspconfig.texlab.setup({
on_attach = texlab_config.on_attach,
capabilities = capabilities,
settings = texlab_config.settings,
})
end,
})
end,
dependencies = { "neovim/nvim-lspconfig", "jose-elias-alvarez/null-ls.nvim" },
},
}
+18
View File
@@ -0,0 +1,18 @@
local M = {
on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
end,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
}
return M
+7
View File
@@ -0,0 +1,7 @@
local M = {
on_attach = function(client, bufnr)
-- Adopting Black formater in python
client.server_capabilities.documentFormattingProvider = false -- 0.8 and later
end,
}
return M
+24
View File
@@ -0,0 +1,24 @@
local M = {
on_attach = function(client, bufnr)
vim.keymap.set("n", "<Leader>lb", "<Cmd>TexlabBuild<CR>", { desc = "Texlab Build", buffer = bufnr })
vim.keymap.set("n", "<Leader>lf", "<Cmd>TexlabForward<CR>", { desc = "Texlab Forward", buffer = bufnr })
vim.keymap.set("i", "<C-b>", "<Cmd>TexlabBuild<CR>", { desc = "Texlab Build", buffer = bufnr })
vim.keymap.set("i", "<C-f>", "<Cmd>TexlabForward<CR>", { desc = "Texlab Forward", buffer = bufnr })
end,
settings = {
texlab = {
build = {
executable = "latexmk",
args = { "-interaction=nonstopmode", "-synctex=1" },
onSave = true,
forwardSearchAfter = false,
},
forwardSearch = {
executable = "SumatraPDF.exe",
args = { "-reuse-instance", "%p", "-forward-search", "%f", "%l" },
},
},
},
}
return M
+68
View File
@@ -0,0 +1,68 @@
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 = "",
},
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,
},
},
{ "filename", path = 1 },
},
lualine_x = { "searchcount", lsp_status, "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
-- winbar = {
-- lualine_a = {},
-- lualine_b = {},
-- lualine_c = { { "filename", path = 1 } },
-- lualine_x = {},
-- lualine_y = {},
-- lualine_z = {},
-- },
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = { "nvim-tree", "lazy", "symbols-outline", "toggleterm" },
},
},
}
+15
View File
@@ -0,0 +1,15 @@
return {
{
"jose-elias-alvarez/null-ls.nvim",
lazy = true,
opts = function()
local null_ls = require("null-ls")
return {
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.black,
},
}
end,
},
}
+48
View File
@@ -0,0 +1,48 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = {
"nvim-tree/nvim-web-devicons", -- optional, for file icon
},
lazy = false,
opts = {
-- open_on_tab = true,
sync_root_with_cwd = 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(_, opts)
require("nvim-tree").setup(opts)
local function open_nvim_tree()
-- open the tree
require("nvim-tree.api").tree.toggle({ focus = false, find_file = true })
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"
}}
}
+80
View File
@@ -0,0 +1,80 @@
-- This functions is to fix a bug in telescope
-- that the fold not word if open file in telescope
-- https://github.com/nvim-telescope/telescope.nvim/issues/559#issuecomment-1221001701
local function stopinsert(callback)
return function(prompt_bufnr)
vim.cmd.stopinsert()
vim.schedule(function()
callback(prompt_bufnr)
end)
end
end
return {
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
cmd = "Telescope",
branch = "0.1.x",
config = function()
local actions = require("telescope.actions")
require("telescope").setup({
defaults = {
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-f>"] = actions.preview_scrolling_down,
["<C-b>"] = actions.preview_scrolling_up,
["<Esc>"] = actions.close, -- As we don't use normal node in telescope
["<CR>"] = stopinsert(actions.select_default),
["<C-v>"] = stopinsert(actions.select_vertical),
["<C-x>"] = stopinsert(actions.select_horizontal),
["<C-t>"] = stopinsert(actions.select_tab),
},
n = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-f>"] = actions.preview_scrolling_down,
["<C-b>"] = actions.preview_scrolling_up,
["q"] = actions.close,
},
},
},
pickers = {
colorscheme = {
enable_preview = true,
theme = "dropdown",
},
},
})
end,
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",
},
{
"<Leader>ft",
"<Cmd>Telescope colorscheme<CR>",
desc = "Find Theme",
},
},
},
}
+14
View File
@@ -0,0 +1,14 @@
return {
-- tokyonight
{
"folke/tokyonight.nvim",
lazy = true,
opts = { style = "moon" },
},
-- catppuccin
{
"catppuccin/nvim",
lazy = true,
name = "catppuccin",
},
}
+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", "yaml"},
highlight = {
enable = true
}
},
---@param opts TSConfig
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end
}
+1
View File
@@ -0,0 +1 @@
indent_type = "Spaces"