first commit
This commit is contained in:
commit
fddc5eeed2
|
|
@ -0,0 +1 @@
|
||||||
|
plugin
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
vim.defer_fn(function()
|
||||||
|
pcall(require, "impatient")
|
||||||
|
end, 0)
|
||||||
|
|
||||||
|
-- setup packer + plugins
|
||||||
|
local fn = vim.fn
|
||||||
|
local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim"
|
||||||
|
|
||||||
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
|
||||||
|
print "Cloning packer .."
|
||||||
|
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
|
||||||
|
|
||||||
|
-- install plugins + compile their configs
|
||||||
|
vim.cmd "packadd packer.nvim"
|
||||||
|
require "plugins"
|
||||||
|
vim.cmd "PackerSync"
|
||||||
|
end
|
||||||
|
|
||||||
|
local modules = {
|
||||||
|
"core.options",
|
||||||
|
"core.packer",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, module in ipairs(modules) do
|
||||||
|
local ok, err = pcall(require, module)
|
||||||
|
if not ok then
|
||||||
|
error("Error loading " .. module .. "\n\n" .. err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require ("core.utils").load_mappings()
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
local M = {}
|
||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
|
||||||
|
-- require("packer").loader(tb.plugins)
|
||||||
|
-- This must be used for plugins that need to be loaded just after a file
|
||||||
|
-- ex : treesitter, lspconfig etc
|
||||||
|
M.lazy_load = function(tb)
|
||||||
|
autocmd(tb.events, {
|
||||||
|
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
||||||
|
callback = function()
|
||||||
|
if tb.condition() then
|
||||||
|
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
|
||||||
|
|
||||||
|
-- dont defer for treesitter as it will show slow highlighting
|
||||||
|
-- This deferring only happens only when we do "nvim filename"
|
||||||
|
if tb.plugin ~= "nvim-treesitter" then
|
||||||
|
vim.defer_fn(function()
|
||||||
|
require("packer").loader(tb.plugin)
|
||||||
|
if tb.plugin == "nvim-lspconfig" then
|
||||||
|
vim.cmd "silent! do FileType"
|
||||||
|
end
|
||||||
|
end, 0)
|
||||||
|
else
|
||||||
|
require("packer").loader(tb.plugin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- load certain plugins only when there's a file opened in the buffer
|
||||||
|
-- if "nvim filename" is executed -> load the plugin after nvim gui loads
|
||||||
|
-- This gives an instant preview of nvim with the file opened
|
||||||
|
|
||||||
|
M.on_file_open = function(plugin_name)
|
||||||
|
M.lazy_load {
|
||||||
|
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||||
|
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
|
||||||
|
plugin = plugin_name,
|
||||||
|
condition = function()
|
||||||
|
local file = vim.fn.expand "%"
|
||||||
|
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.packer_cmds = {
|
||||||
|
"PackerSnapshot",
|
||||||
|
"PackerSnapshotRollback",
|
||||||
|
"PackerSnapshotDelete",
|
||||||
|
"PackerInstall",
|
||||||
|
"PackerUpdate",
|
||||||
|
"PackerSync",
|
||||||
|
"PackerClean",
|
||||||
|
"PackerCompile",
|
||||||
|
"PackerStatus",
|
||||||
|
"PackerProfile",
|
||||||
|
"PackerLoad",
|
||||||
|
}
|
||||||
|
M.treesitter_cmds = {
|
||||||
|
"TSInstall",
|
||||||
|
"TSBufEnable",
|
||||||
|
"TSBufDisable",
|
||||||
|
"TSEnable",
|
||||||
|
"TSDisable",
|
||||||
|
"TSModuleInfo",
|
||||||
|
}
|
||||||
|
|
||||||
|
M.gitsigns = function()
|
||||||
|
autocmd({ "BufRead" }, {
|
||||||
|
callback = function()
|
||||||
|
vim.fn.system("git rev-parse " .. vim.fn.expand "%:p:h")
|
||||||
|
if vim.v.shell_error == 0 then
|
||||||
|
vim.schedule(function()
|
||||||
|
require("packer").loader "gitsigns.nvim"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.general = {
|
||||||
|
i = {},
|
||||||
|
|
||||||
|
n = {
|
||||||
|
["<ESC>"] = { "<cmd> noh <CR>", "no highlight"},
|
||||||
|
|
||||||
|
-- switch between windows
|
||||||
|
["<C-h>"] = { "<C-w>h", "window left" },
|
||||||
|
["<C-l>"] = { "<C-w>l", "window right" },
|
||||||
|
["<C-j>"] = { "<C-w>j", "window down" },
|
||||||
|
["<C-k>"] = { "<C-w>k", "window up" },
|
||||||
|
|
||||||
|
-- new buffer
|
||||||
|
["<leader>b"] = { "<cmd> enew <CR>", "new buffer" },
|
||||||
|
|
||||||
|
-- close buffer + hide terminal buffer
|
||||||
|
["<leader>x"] = {
|
||||||
|
function()
|
||||||
|
require("core.utils").close_buffer()
|
||||||
|
end,
|
||||||
|
"close buffer",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.telescope = {
|
||||||
|
plugin = true,
|
||||||
|
|
||||||
|
n = {
|
||||||
|
-- find
|
||||||
|
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "find files" },
|
||||||
|
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "find all" },
|
||||||
|
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
|
||||||
|
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
|
||||||
|
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "help page" },
|
||||||
|
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
|
||||||
|
["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", "show keys" },
|
||||||
|
|
||||||
|
-- git
|
||||||
|
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
|
||||||
|
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "git status" },
|
||||||
|
|
||||||
|
-- theme switcher
|
||||||
|
["<leader>th"] = { "<cmd> Telescope colorscheme<CR>", "colorthemes" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.whichkey = {
|
||||||
|
plugin = true,
|
||||||
|
|
||||||
|
n = {
|
||||||
|
["<leader>wK"] = {
|
||||||
|
function()
|
||||||
|
vim.cmd "WhichKey"
|
||||||
|
end,
|
||||||
|
"which-key all keymaps",
|
||||||
|
},
|
||||||
|
["<leader>wk"] = {
|
||||||
|
function()
|
||||||
|
local input = vim.fn.input "WhichKey: "
|
||||||
|
vim.cmd("WhichKey " .. input)
|
||||||
|
end,
|
||||||
|
"which-key query lookup",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.comment = {
|
||||||
|
plugin = true,
|
||||||
|
|
||||||
|
-- toggle comment in both modes
|
||||||
|
n = {
|
||||||
|
["<leader>/"] = {
|
||||||
|
function()
|
||||||
|
require("Comment.api").toggle.linewise.current()
|
||||||
|
end,
|
||||||
|
"toggle comment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
v = {
|
||||||
|
["<leader>/"] = {
|
||||||
|
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
|
||||||
|
"toggle comment",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.blankline = {
|
||||||
|
plugin = true,
|
||||||
|
|
||||||
|
n = {
|
||||||
|
["<leader>cc"] = {
|
||||||
|
function()
|
||||||
|
local ok, start = require("indent_blankline.utils").get_current_context(
|
||||||
|
vim.g.indent_blankline_context_patterns,
|
||||||
|
vim.g.indent_blankline_use_treesitter_scope
|
||||||
|
)
|
||||||
|
|
||||||
|
if ok then
|
||||||
|
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||||
|
vim.cmd [[normal! _]]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
"Jump to current_context",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
local opt = vim.opt
|
||||||
|
local g = vim.g
|
||||||
|
|
||||||
|
-- use filetype.lua instead of filetype.vim. it's enabled by default in neovim 0.8 (nightly)
|
||||||
|
g.vim_version = vim.version().minor
|
||||||
|
if g.vim_version < 8 then
|
||||||
|
g.did_load_filetypes = 0
|
||||||
|
g.do_filetype_lua = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
opt.laststatus = 3 -- global statusline
|
||||||
|
opt.title = true
|
||||||
|
opt.cmdheight = 1
|
||||||
|
opt.clipboard = "unnamedplus"
|
||||||
|
opt.cul = true -- cursor line
|
||||||
|
|
||||||
|
-- numbers
|
||||||
|
opt.number = true
|
||||||
|
opt.numberwidth = 2
|
||||||
|
opt.relativenumber = true
|
||||||
|
opt.ruler = false
|
||||||
|
|
||||||
|
-- indentline
|
||||||
|
opt.expandtab = true
|
||||||
|
opt.shiftwidth = 4
|
||||||
|
opt.smartindent = true
|
||||||
|
|
||||||
|
-- go to previous/next line with h,l,left arrow and right arrow
|
||||||
|
-- when cursor reaches end/beginning of line
|
||||||
|
opt.whichwrap:append "<>[]hl"
|
||||||
|
g.mapleader = " "
|
||||||
|
|
||||||
|
-- disable nvim intro
|
||||||
|
opt.shortmess:append "sI"
|
||||||
|
opt.signcolumn = "yes"
|
||||||
|
opt.termguicolors = true
|
||||||
|
opt.timeoutlen = 400
|
||||||
|
|
||||||
|
|
||||||
|
-- disable some builtin vim plugins
|
||||||
|
local default_plugins = {
|
||||||
|
"2html_plugin",
|
||||||
|
"getscript",
|
||||||
|
"getscriptPlugin",
|
||||||
|
"gzip",
|
||||||
|
"logipat",
|
||||||
|
-- "netrw",
|
||||||
|
-- "netrwPlugin",
|
||||||
|
-- "netrwSettings",
|
||||||
|
-- "netrwFileHandlers",
|
||||||
|
"matchit",
|
||||||
|
"tar",
|
||||||
|
"tarPlugin",
|
||||||
|
"rrhelper",
|
||||||
|
"spellfile_plugin",
|
||||||
|
"vimball",
|
||||||
|
"vimball_plugin",
|
||||||
|
"zip",
|
||||||
|
"zipPlugin",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, plugin in pairs(default_plugins) do
|
||||||
|
g["loaded_" .. plugin ] = 1
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.run = function(plugins)
|
||||||
|
local present, packer = pcall(require, "packer")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local final_table = {}
|
||||||
|
for key, _ in pairs(plugins) do
|
||||||
|
plugins[key][1] = key
|
||||||
|
final_table[#final_table + 1] = plugins[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
packer.init({
|
||||||
|
auto_clean = true,
|
||||||
|
compile_on_sync = true,
|
||||||
|
git = { clone_timeout = 6000 },
|
||||||
|
display = {
|
||||||
|
working_sym = "ﲊ",
|
||||||
|
error_sym = "✗ ",
|
||||||
|
done_sym = " ",
|
||||||
|
removed_sym = " ",
|
||||||
|
moved_sym = "",
|
||||||
|
open_fn = function()
|
||||||
|
return require("packer.util").float { border = "single" }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
packer.startup(function(use)
|
||||||
|
for _, v in pairs(final_table) do
|
||||||
|
use(v)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
local M = {}
|
||||||
|
local merge_tb = vim.tbl_deep_extend
|
||||||
|
|
||||||
|
M.load_mappings = function(section, mapping_opt)
|
||||||
|
local function set_section_map(section_values)
|
||||||
|
if section_values.plugin then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
section_values.plugin = nil
|
||||||
|
|
||||||
|
for mode, mode_values in pairs(section_values) do
|
||||||
|
local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {})
|
||||||
|
for keybind, mapping_info in pairs(mode_values) do
|
||||||
|
-- merge default + user opts
|
||||||
|
local opts = merge_tb("force", default_opts, mapping_info.opts or {})
|
||||||
|
|
||||||
|
mapping_info.opts, opts.mode = nil, nil
|
||||||
|
opts.desc = mapping_info[2]
|
||||||
|
|
||||||
|
vim.keymap.set(mode, keybind, mapping_info[1], opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local mappings = require("core.mappings")
|
||||||
|
|
||||||
|
if type(section) == "string" then
|
||||||
|
mappings[section]["plugin"] = nil
|
||||||
|
mappings = { mappings[section] }
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, sect in pairs(mappings) do
|
||||||
|
set_section_map(sect)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
local present, cmp = pcall(require, "cmp")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.completeopt = "menuone,noselect"
|
||||||
|
|
||||||
|
local function border(hl_name)
|
||||||
|
return {
|
||||||
|
{ "╭", hl_name },
|
||||||
|
{ "─", hl_name },
|
||||||
|
{ "╮", hl_name },
|
||||||
|
{ "│", hl_name },
|
||||||
|
{ "╯", hl_name },
|
||||||
|
{ "─", hl_name },
|
||||||
|
{ "╰", hl_name },
|
||||||
|
{ "│", hl_name },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmp_window = require "cmp.utils.window"
|
||||||
|
|
||||||
|
cmp_window.info_ = cmp_window.info
|
||||||
|
cmp_window.info = function(self)
|
||||||
|
local info = self:info_()
|
||||||
|
info.scrollable = false
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
window = {
|
||||||
|
completion = {
|
||||||
|
border = border "CmpBorder",
|
||||||
|
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
||||||
|
},
|
||||||
|
documentation = {
|
||||||
|
border = border "CmpDocBorder",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<C-e>"] = cmp.mapping.close(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = false,
|
||||||
|
},
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif require("luasnip").expand_or_jumpable() then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif require("luasnip").jumpable(-1) then
|
||||||
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "path" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- check for any override
|
||||||
|
|
||||||
|
cmp.setup(options)
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
-- 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', vim.lsp.buf.formatting, bufopts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local lsp_flags = {
|
||||||
|
-- This is the default in Nvim 0.7+
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
require('lspconfig')['sumneko_lua'].setup{
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = {
|
||||||
|
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
|
||||||
|
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
|
||||||
|
},
|
||||||
|
maxpreload = 100000,
|
||||||
|
preloadFileSize = 10000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lspconfig')['rust_analyzer'].setup{
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
-- Server-specific settings...
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
local present, mason = pcall(require, "mason")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
|
||||||
|
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
package_pending = " ",
|
||||||
|
package_installed = " ",
|
||||||
|
package_uninstalled = "ﮊ ",
|
||||||
|
},
|
||||||
|
|
||||||
|
keymaps = {
|
||||||
|
toggle_server_expand = "<CR>",
|
||||||
|
install_server = "i",
|
||||||
|
update_server = "u",
|
||||||
|
check_server_version = "c",
|
||||||
|
update_all_servers = "U",
|
||||||
|
check_outdated_servers = "C",
|
||||||
|
uninstall_server = "X",
|
||||||
|
cancel_installation = "<C-c>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
max_concurrent_installers = 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
mason.setup(options)
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.autopairs = function()
|
||||||
|
local present1, autopairs = pcall(require, "nvim-autopairs")
|
||||||
|
local present2, cmp = pcall(require, "cmp")
|
||||||
|
|
||||||
|
if not (present1 and present2) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
fast_wrap = {},
|
||||||
|
disable_filetype = { "TelescopePrompt", "vim" },
|
||||||
|
}
|
||||||
|
|
||||||
|
autopairs.setup(options)
|
||||||
|
|
||||||
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||||
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||||
|
end
|
||||||
|
|
||||||
|
M.luasnip = function()
|
||||||
|
local present, luasnip = pcall(require, "luasnip")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
history = true,
|
||||||
|
updateevents = "TextChanged,TextChangedI",
|
||||||
|
}
|
||||||
|
|
||||||
|
luasnip.config.set_config(options)
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||||
|
callback = function()
|
||||||
|
if
|
||||||
|
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
|
||||||
|
and not require("luasnip").session.jump_active
|
||||||
|
then
|
||||||
|
require("luasnip").unlink_current()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.gitsigns = function()
|
||||||
|
local present, gitsigns = pcall(require, "gitsigns")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
signs = {
|
||||||
|
add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" },
|
||||||
|
change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" },
|
||||||
|
delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
|
||||||
|
topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" },
|
||||||
|
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
gitsigns.setup(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.blankline = function()
|
||||||
|
local present, blankline = pcall(require, "indent_blankline")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
indentLine_enabled = 1,
|
||||||
|
char = "▏",
|
||||||
|
filetype_exclude = {
|
||||||
|
"help",
|
||||||
|
"terminal",
|
||||||
|
"alpha",
|
||||||
|
"packer",
|
||||||
|
"lspinfo",
|
||||||
|
"TelescopePrompt",
|
||||||
|
"TelescopeResults",
|
||||||
|
"nvchad_cheatsheet",
|
||||||
|
"lsp-installer",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
buftype_exclude = { "terminal" },
|
||||||
|
show_trailing_blankline_indent = false,
|
||||||
|
show_first_indent_level = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
blankline.setup(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.colorizer = function()
|
||||||
|
local present, colorizer = pcall(require, "colorizer")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
filetypes = {
|
||||||
|
"*",
|
||||||
|
},
|
||||||
|
user_default_options = {
|
||||||
|
RGB = true, -- #RGB hex codes
|
||||||
|
RRGGBB = true, -- #RRGGBB hex codes
|
||||||
|
names = false, -- "Name" codes like Blue
|
||||||
|
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||||
|
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||||
|
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||||
|
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||||
|
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||||
|
mode = "background", -- Set the display mode.
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
colorizer.setup(options)
|
||||||
|
return vim.tbl_isempty(options.filetypes or {}) or vim.cmd [[do FileType]]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
M.comment = function()
|
||||||
|
local present, nvim_comment = pcall(require, "Comment")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {}
|
||||||
|
nvim_comment.setup(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
local present, rust = pcall(require, "rust-tools")
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
tools = {
|
||||||
|
on_initialized = nil,
|
||||||
|
reload_workspace_from_cargo_toml = true,
|
||||||
|
|
||||||
|
-- inlay hints
|
||||||
|
inlay_hints = {
|
||||||
|
auto = true,
|
||||||
|
only_current_line = false,
|
||||||
|
show_parameter_hints = true,
|
||||||
|
parameter_hints_prefix = "<- ",
|
||||||
|
max_len_align = false,
|
||||||
|
},
|
||||||
|
enabled_graphviz_backends = {
|
||||||
|
"bmp",
|
||||||
|
"cgimage",
|
||||||
|
"canon",
|
||||||
|
"dot",
|
||||||
|
"gv",
|
||||||
|
"xdot",
|
||||||
|
"xdot1.2",
|
||||||
|
"xdot1.4",
|
||||||
|
"eps",
|
||||||
|
"exr",
|
||||||
|
"fig",
|
||||||
|
"gd",
|
||||||
|
"gd2",
|
||||||
|
"gif",
|
||||||
|
"gtk",
|
||||||
|
"ico",
|
||||||
|
"cmap",
|
||||||
|
"ismap",
|
||||||
|
"imap",
|
||||||
|
"cmapx",
|
||||||
|
"imap_np",
|
||||||
|
"cmapx_np",
|
||||||
|
"jpg",
|
||||||
|
"jpeg",
|
||||||
|
"jpe",
|
||||||
|
"jp2",
|
||||||
|
"json",
|
||||||
|
"json0",
|
||||||
|
"dot_json",
|
||||||
|
"xdot_json",
|
||||||
|
"pdf",
|
||||||
|
"pic",
|
||||||
|
"pct",
|
||||||
|
"pict",
|
||||||
|
"plain",
|
||||||
|
"plain-ext",
|
||||||
|
"png",
|
||||||
|
"pov",
|
||||||
|
"ps",
|
||||||
|
"ps2",
|
||||||
|
"psd",
|
||||||
|
"sgi",
|
||||||
|
"svg",
|
||||||
|
"svgz",
|
||||||
|
"tga",
|
||||||
|
"tiff",
|
||||||
|
"tif",
|
||||||
|
"tk",
|
||||||
|
"vml",
|
||||||
|
"vmlz",
|
||||||
|
"wbmp",
|
||||||
|
"webp",
|
||||||
|
"xlib",
|
||||||
|
"x11",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rust.setup(options)
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
require('lualine').setup {
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = 'auto',
|
||||||
|
component_separators = { left = '', right = ''},
|
||||||
|
section_separators = { left = '', right = ''},
|
||||||
|
disabled_filetypes = {
|
||||||
|
statusline = {},
|
||||||
|
winbar = {},
|
||||||
|
},
|
||||||
|
ignore_focus = {},
|
||||||
|
always_divide_middle = true,
|
||||||
|
globalstatus = false,
|
||||||
|
refresh = {
|
||||||
|
statusline = 1000,
|
||||||
|
tabline = 1000,
|
||||||
|
winbar = 1000,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = {'mode'},
|
||||||
|
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||||
|
lualine_c = {'filename'},
|
||||||
|
lualine_x = {'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 = {},
|
||||||
|
winbar = {},
|
||||||
|
inactive_winbar = {},
|
||||||
|
extensions = {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
local present, telescope = pcall(require, "telescope")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.g.theme_switcher_loaded = true
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
defaults = {
|
||||||
|
vimgrep_arguments = {
|
||||||
|
"rg",
|
||||||
|
"--color=never",
|
||||||
|
"--no-heading",
|
||||||
|
"--with-filename",
|
||||||
|
"--line-number",
|
||||||
|
"--column",
|
||||||
|
"--smart-case",
|
||||||
|
},
|
||||||
|
prompt_prefix = " ",
|
||||||
|
selection_caret = " ",
|
||||||
|
entry_prefix = " ",
|
||||||
|
initial_mode = "insert",
|
||||||
|
selection_strategy = "reset",
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
layout_strategy = "horizontal",
|
||||||
|
layout_config = {
|
||||||
|
horizontal = {
|
||||||
|
prompt_position = "top",
|
||||||
|
preview_width = 0.55,
|
||||||
|
results_width = 0.8,
|
||||||
|
},
|
||||||
|
vertical = {
|
||||||
|
mirror = false,
|
||||||
|
},
|
||||||
|
width = 0.87,
|
||||||
|
height = 0.80,
|
||||||
|
preview_cutoff = 120,
|
||||||
|
},
|
||||||
|
file_sorter = require("telescope.sorters").get_fuzzy_file,
|
||||||
|
file_ignore_patterns = { "node_modules" },
|
||||||
|
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
|
||||||
|
path_display = { "truncate" },
|
||||||
|
winblend = 0,
|
||||||
|
border = {},
|
||||||
|
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||||
|
color_devicons = true,
|
||||||
|
set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
|
||||||
|
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
|
||||||
|
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
|
||||||
|
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
|
||||||
|
-- Developer configurations: Not meant for general override
|
||||||
|
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
|
||||||
|
mappings = {
|
||||||
|
n = { ["q"] = require("telescope.actions").close },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
extensions_list = { "themes", "terms" },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- check for any override
|
||||||
|
telescope.setup(options)
|
||||||
|
|
||||||
|
-- load extensions
|
||||||
|
pcall(function()
|
||||||
|
for _, ext in ipairs(options.extensions_list) do
|
||||||
|
telescope.load_extension(ext)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
local present, treesitter = pcall(require, "nvim-treesitter.configs")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
ensure_installed = {
|
||||||
|
"lua",
|
||||||
|
"rust",
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
use_languagetree = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
treesitter.setup(options)
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
local present, wk = pcall(require, "which-key")
|
||||||
|
|
||||||
|
if not present then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
|
||||||
|
icons = {
|
||||||
|
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
||||||
|
separator = " ", -- symbol used between a key and it's label
|
||||||
|
group = "+", -- symbol prepended to a group
|
||||||
|
},
|
||||||
|
|
||||||
|
popup_mappings = {
|
||||||
|
scroll_down = "<c-d>", -- binding to scroll down inside the popup
|
||||||
|
scroll_up = "<c-u>", -- binding to scroll up inside the popup
|
||||||
|
},
|
||||||
|
|
||||||
|
window = {
|
||||||
|
border = "none", -- none/single/double/shadow
|
||||||
|
},
|
||||||
|
|
||||||
|
layout = {
|
||||||
|
spacing = 6, -- spacing between columns
|
||||||
|
},
|
||||||
|
|
||||||
|
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " },
|
||||||
|
|
||||||
|
triggers_blacklist = {
|
||||||
|
-- list of mode / prefixes that should never be hooked by WhichKey
|
||||||
|
i = { "j", "k" },
|
||||||
|
v = { "j", "k" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
wk.setup(options)
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
vim.cmd "packadd packer.nvim"
|
||||||
|
|
||||||
|
local plugins = {
|
||||||
|
["wbthomason/packer.nvim"] = {
|
||||||
|
cmd = require("core.lazy_load").packer_cmds,
|
||||||
|
config = function()
|
||||||
|
require "plugins"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["luisiacc/gruvbox-baby"] = {
|
||||||
|
config ="vim.cmd 'colorscheme gruvbox-baby'"
|
||||||
|
},
|
||||||
|
|
||||||
|
["nvim-treesitter/nvim-treesitter"] = {
|
||||||
|
module = "nvim-treesitter",
|
||||||
|
setup = function()
|
||||||
|
require("core.lazy_load").on_file_open "nvim-treesitter"
|
||||||
|
end,
|
||||||
|
cmd = require("core.lazy_load").treesitter_cmds,
|
||||||
|
run = ":TSUpdate",
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.treesitter"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- git
|
||||||
|
["lewis6991/gitsigns.nvim"] = {
|
||||||
|
ft = "gitcommit",
|
||||||
|
setup = function()
|
||||||
|
require("core.lazy_load").gitsigns()
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").gitsigns()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
['nvim-lua/plenary.nvim'] = {},
|
||||||
|
|
||||||
|
["nvim-telescope/telescope.nvim"] = {
|
||||||
|
cmd = "Telescope",
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.telescope"
|
||||||
|
end,
|
||||||
|
setup = function ()
|
||||||
|
require ("core.utils").load_mappings "telescope"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- lsp stuff
|
||||||
|
|
||||||
|
["williamboman/mason.nvim"] = {
|
||||||
|
cmd = require("core.lazy_load").mason_cmds,
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.mason"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["neovim/nvim-lspconfig"] = {
|
||||||
|
opt = true,
|
||||||
|
setup = function()
|
||||||
|
require("core.lazy_load").on_file_open "nvim-lspconfig"
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.lspconfig"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["simrat39/rust-tools.nvim"] = {
|
||||||
|
ft = "rs",
|
||||||
|
config = function ()
|
||||||
|
require("plugins.configs.rust-tools")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- load luasnips + cmp related in insert mode only
|
||||||
|
|
||||||
|
["rafamadriz/friendly-snippets"] = {
|
||||||
|
module = { "cmp", "cmp_nvim_lsp" },
|
||||||
|
event = "InsertEnter",
|
||||||
|
},
|
||||||
|
|
||||||
|
["hrsh7th/nvim-cmp"] = {
|
||||||
|
after = "friendly-snippets",
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.cmp"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["L3MON4D3/LuaSnip"] = {
|
||||||
|
wants = "friendly-snippets",
|
||||||
|
after = "nvim-cmp",
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").luasnip()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["saadparwaiz1/cmp_luasnip"] = {
|
||||||
|
after = "LuaSnip",
|
||||||
|
},
|
||||||
|
|
||||||
|
["hrsh7th/cmp-nvim-lua"] = {
|
||||||
|
after = "cmp_luasnip",
|
||||||
|
},
|
||||||
|
|
||||||
|
["hrsh7th/cmp-nvim-lsp"] = {
|
||||||
|
after = "cmp-nvim-lua",
|
||||||
|
},
|
||||||
|
|
||||||
|
["hrsh7th/cmp-buffer"] = {
|
||||||
|
after = "cmp-nvim-lsp",
|
||||||
|
},
|
||||||
|
|
||||||
|
["hrsh7th/cmp-path"] = {
|
||||||
|
after = "cmp-buffer",
|
||||||
|
},
|
||||||
|
|
||||||
|
-- misc
|
||||||
|
["windwp/nvim-autopairs"] = {
|
||||||
|
after = "nvim-cmp",
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").autopairs()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["numToStr/Comment.nvim"] = {
|
||||||
|
module = "Comment",
|
||||||
|
keys = { "gc", "gb" },
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").comment()
|
||||||
|
end,
|
||||||
|
setup = function()
|
||||||
|
require("core.utils").load_mappings "comment"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- UI stuff
|
||||||
|
["lukas-reineke/indent-blankline.nvim"] = {
|
||||||
|
event = "BufRead",
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").blankline()
|
||||||
|
end,
|
||||||
|
setup = function()
|
||||||
|
require("core.utils").load_mappings "blankline"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["krolyxon/nvim-colorizer.lua"] = {
|
||||||
|
opt = true,
|
||||||
|
setup = function ()
|
||||||
|
require("core.lazy_load").on_file_open "nvim-colorizer.lua"
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.others").colorizer()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
["nvim-lualine/lualine.nvim"] = {
|
||||||
|
config = function()
|
||||||
|
require("plugins.configs.statusline")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Only load whichkey after all the gui
|
||||||
|
["folke/which-key.nvim"] = {
|
||||||
|
disable = false,
|
||||||
|
module = "which-key",
|
||||||
|
keys = "<leader>",
|
||||||
|
config = function()
|
||||||
|
require "plugins.configs.whichkey"
|
||||||
|
end,
|
||||||
|
setup = function()
|
||||||
|
require("core.utils").load_mappings "whichkey"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- speed up deffered plugins
|
||||||
|
["lewis6991/impatient.nvim"] = {},
|
||||||
|
}
|
||||||
|
require("core.packer").run(plugins)
|
||||||
Reference in New Issue