update
This commit is contained in:
3
lua/core/init.lua
Normal file
3
lua/core/init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
require("core.options")
|
||||
require("core.keymaps")
|
||||
require("core.lazy")
|
||||
19
lua/core/keymaps.lua
Normal file
19
lua/core/keymaps.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Use native Neovim Lua keymap API
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "<leader>h", "<C-w>h", { noremap = true, silent = true })
|
||||
keymap.set("n", "<leader>j", "<C-w>j", { noremap = true, silent = true })
|
||||
keymap.set("n", "<leader>k", "<C-w>k", { noremap = true, silent = true })
|
||||
keymap.set("n", "<leader>l", "<C-w>l", { noremap = true, silent = true })
|
||||
|
||||
local reload = require("utils.reload")
|
||||
|
||||
vim.api.nvim_create_user_command("ReloadConfig", reload.reload, {})
|
||||
vim.keymap.set("n", "<leader><leader>r", reload.reload, { noremap = true, silent = true })
|
||||
|
||||
keymap.set("n", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>", {noremap = true, silent = true})
|
||||
keymap.set("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>" , {noremap = true, silent = true})
|
||||
keymap.set("n", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>" , {noremap = true, silent = true})
|
||||
keymap.set("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>" , {noremap = true, silent = true})
|
||||
|
||||
vim.keymap.set("n", "gn", vim.diagnostic.goto_next, { noremap = true, silent = true })
|
||||
13
lua/core/lazy.lua
Normal file
13
lua/core/lazy.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
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",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- load plugin list
|
||||
require("lazy").setup(require("plugins"))
|
||||
|
||||
16
lua/core/options.lua
Normal file
16
lua/core/options.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- core/options.lua
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.expandtab = false
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.tabstop = 8
|
||||
vim.opt.colorcolumn = "80"
|
||||
vim.opt.clipboard="unnamedplus"
|
||||
vim.g.mapleader = " "
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
vim.o.undofile = true
|
||||
vim.o.undodir = vim.fn.stdpath("data") .. "/undo//"
|
||||
3
lua/init.lua
Normal file
3
lua/init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
-- Load core config
|
||||
require("core")
|
||||
|
||||
24
lua/lazy-lock.json
Normal file
24
lua/lazy-lock.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
|
||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||
"gruvbox-material": { "branch": "master", "commit": "834dbf21836862300ced7444db4262b796330ab7" },
|
||||
"indentmini.nvim": { "branch": "main", "commit": "e0f1e381a3949ea6757365fa33f8f1722d3eae90" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
|
||||
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||
"nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "e397756d2a79d74314ea4cd3efc41300e91c0ff0" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||
"venn.nvim": { "branch": "main", "commit": "b09c2f36ddf70b498281845109bedcf08a7e0de0" }
|
||||
}
|
||||
43
lua/plugins/config/cmp.lua
Normal file
43
lua/plugins/config/cmp.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
|
||||
41
lua/plugins/config/lsp.lua
Normal file
41
lua/plugins/config/lsp.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--local lspconfig = require("lspconfig")
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
|
||||
-- Setup capabilities for nvim-cmp completion
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
-- Common on_attach function to map keys after LSP attaches to buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local bufmap = function(mode, lhs, rhs)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, { noremap = true, silent = true })
|
||||
end
|
||||
|
||||
-- LSP-related keymaps
|
||||
bufmap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>")
|
||||
bufmap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>")
|
||||
bufmap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
|
||||
bufmap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
bufmap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
|
||||
bufmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
|
||||
bufmap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>")
|
||||
end
|
||||
|
||||
-- List of servers to setup
|
||||
local servers = {
|
||||
"pyright",
|
||||
"clangd",
|
||||
"zls",
|
||||
"lua_ls",
|
||||
"vimls",
|
||||
"marksman",
|
||||
"texlab",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
vim.lsp.config(server, {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
-- Enable the server configuration
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
8
lua/plugins/config/lualine.lua
Normal file
8
lua/plugins/config/lualine.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "auto",
|
||||
section_separators = "",
|
||||
component_separators = "",
|
||||
},
|
||||
})
|
||||
|
||||
9
lua/plugins/config/nvimtree.lua
Normal file
9
lua/plugins/config/nvimtree.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
require("nvim-tree").setup({
|
||||
sort = { sorter = "case_sensitive" },
|
||||
view = { width = 30 },
|
||||
renderer = { group_empty = true },
|
||||
filters = { dotfiles = true },
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>", { noremap = true, silent = true })
|
||||
|
||||
41
lua/plugins/config/treesitter.lua
Normal file
41
lua/plugins/config/treesitter.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the listed parsers MUST always be installed)
|
||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "zig" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
-- List of parsers to ignore installing (or "all")
|
||||
ignore_install = { "javascript" },
|
||||
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
||||
-- the name of the parser)
|
||||
-- list of language that will be disabled
|
||||
disable = { "c", "rust" },
|
||||
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
29
lua/plugins/config/venn.lua
Normal file
29
lua/plugins/config/venn.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
-- Function to toggle venn keymaps
|
||||
function _G.Toggle_venn()
|
||||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||
if venn_enabled == "nil" then
|
||||
vim.b.venn_enabled = true
|
||||
vim.cmd([[setlocal ve=all]])
|
||||
-- Draw a line on HJKL keystrokes
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true, silent = true })
|
||||
-- Draw a box with visual selection
|
||||
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true, silent = true })
|
||||
else
|
||||
vim.cmd([[setlocal ve=]])
|
||||
vim.api.nvim_buf_del_keymap(0, "n", "J")
|
||||
vim.api.nvim_buf_del_keymap(0, "n", "K")
|
||||
vim.api.nvim_buf_del_keymap(0, "n", "L")
|
||||
vim.api.nvim_buf_del_keymap(0, "n", "H")
|
||||
vim.api.nvim_buf_del_keymap(0, "v", "f")
|
||||
vim.b.venn_enabled = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Toggle venn with <leader>v globally
|
||||
vim.api.nvim_set_keymap("n", "<leader>v", ":lua Toggle_venn()<CR>", { noremap = true, silent = true })
|
||||
|
||||
|
||||
98
lua/plugins/init.lua
Normal file
98
lua/plugins/init.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = 'master',
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("plugins.config.treesitter")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("plugins.config.nvimtree")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
config = function()
|
||||
require("plugins.config.lualine")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"sainnhe/gruvbox-material",
|
||||
config = function()
|
||||
vim.cmd([[colorscheme gruvbox-material]])
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua", -- only load on lua files
|
||||
opts = {
|
||||
library = {
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"williamboman/nvim-lsp-installer",
|
||||
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require("plugins.config.lsp")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"rafamadriz/friendly-snippets",
|
||||
},
|
||||
config = function()
|
||||
require("plugins.config.cmp")
|
||||
end,
|
||||
},
|
||||
{
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||
},
|
||||
{
|
||||
'nvimdev/indentmini.nvim',
|
||||
config = function()
|
||||
require("indentmini").setup() -- use default config
|
||||
vim.cmd('hi default link IndentLine Comment')
|
||||
vim.cmd.highlight('IndentLine guifg=#89b482')
|
||||
vim.cmd.highlight('IndentLineCurrent guifg=#e78a4e')
|
||||
end,
|
||||
},
|
||||
{
|
||||
'jbyuki/venn.nvim',
|
||||
config = function()
|
||||
require("plugins.config.venn")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"iamcco/markdown-preview.nvim",
|
||||
build = "cd app && npm install",
|
||||
cmd = { "MarkdownPreview", "MarkdownPreviewToggle", "MarkdownPreviewStop" },
|
||||
ft = { "markdown" },
|
||||
config = function()
|
||||
vim.g.mkdp_auto_start = 0
|
||||
vim.g.mkdp_auto_close = 1
|
||||
vim.g.mkdp_browser = "/usr/bin/zen-browser"
|
||||
vim.g.mkdp_theme = "dark"
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
130
lua/user/cmp.lua
130
lua/user/cmp.lua
@@ -1,130 +0,0 @@
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
if not snip_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
|
||||
local check_backspace = function()
|
||||
local col = vim.fn.col "." - 1
|
||||
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
|
||||
end
|
||||
|
||||
-- פּ ﯟ some other good icons
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "m",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
["<C-e>"] = cmp.mapping {
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
},
|
||||
-- Accept currently selected item. If none selected, `select` first item.
|
||||
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif check_backspace() then
|
||||
fallback()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
path = "[Path]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
documentation = {
|
||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = false,
|
||||
native_menu = false,
|
||||
},
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
vim.cmd [[
|
||||
try
|
||||
colorscheme gruvbox-material
|
||||
catch /^Vim\%((\a\+)\)\=:E185/
|
||||
colorscheme default
|
||||
set background=dark
|
||||
endtry
|
||||
]]
|
||||
@@ -1,48 +0,0 @@
|
||||
local status_ok, gitsigns = pcall(require, "gitsigns")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
gitsigns.setup {
|
||||
signs = {
|
||||
add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
|
||||
change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
||||
delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||
topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||
changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = false,
|
||||
},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
local term_opts = { silent = true }
|
||||
|
||||
-- Shorten function name
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
|
||||
--Remap space as leader key
|
||||
keymap("", "<Space>", "<Nop>", opts)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Modes
|
||||
-- normal_mode = "n",
|
||||
-- insert_mode = "i",
|
||||
-- visual_mode = "v",
|
||||
-- visual_block_mode = "x",
|
||||
-- term_mode = "t",
|
||||
-- command_mode = "c",
|
||||
|
||||
-- Normal --
|
||||
-- Better window navigation
|
||||
keymap("n", "<leader>h", ":wincmd h<CR>", opts)
|
||||
keymap("n", "<leader>j", ":wincmd j<CR>", opts)
|
||||
keymap("n", "<leader>k", ":wincmd k<CR>", opts)
|
||||
keymap("n", "<leader>l", ":wincmd l<CR>", opts)
|
||||
|
||||
keymap("n", "<C-n>", ":NvimTreeToggle<CR>", opts)
|
||||
|
||||
-- window size up / down
|
||||
keymap("n", "<leader>+", ":vertical resize +5<CR>", opts)
|
||||
keymap("n", "<leader>-", ":vertical resize -5<CR>", opts)
|
||||
|
||||
-- Telescope
|
||||
keymap("n", "<leader>ff" , "<cmd>lua require('telescope.builtin').find_files({hidden = true})<cr>",opts)
|
||||
keymap("n", "<leader>fg" , "<cmd>lua require('telescope.builtin').live_grep()<cr>",opts)
|
||||
keymap("n", "<leader>fb" , "<cmd>lua require('telescope.builtin').buffers()<cr>",opts)
|
||||
keymap("n", "<leader>fh" , "<cmd>lua require('telescope.builtin').help_tags()<cr>",opts)
|
||||
@@ -1,24 +0,0 @@
|
||||
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
local servers = { "jsonls", "lua_ls" , "pyright", "gopls", "ccls", "rust_analyzer"}
|
||||
|
||||
lsp_installer.setup({
|
||||
ensure_installed = servers,
|
||||
})
|
||||
|
||||
for _, server in pairs(servers) do
|
||||
local opts = {
|
||||
on_attach = require("user.lsp.handlers").on_attach,
|
||||
capabilities = require("user.lsp.handlers").capabilities,
|
||||
}
|
||||
local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server)
|
||||
if has_custom_opts then
|
||||
opts = vim.tbl_deep_extend("force", opts, server_custom_opts)
|
||||
end
|
||||
lspconfig[server].setup(opts)
|
||||
end
|
||||
@@ -1,102 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
-- TODO: backfill this to template
|
||||
M.setup = function()
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = "" },
|
||||
{ name = "DiagnosticSignWarn", text = "" },
|
||||
{ name = "DiagnosticSignHint", text = "" },
|
||||
{ name = "DiagnosticSignInfo", text = "" },
|
||||
}
|
||||
|
||||
for _, sign in ipairs(signs) do
|
||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||
end
|
||||
|
||||
local config = {
|
||||
-- disable virtual text
|
||||
virtual_text = false,
|
||||
-- show signs
|
||||
signs = {
|
||||
active = signs,
|
||||
},
|
||||
update_in_insert = true,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
}
|
||||
|
||||
vim.diagnostic.config(config)
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = "rounded",
|
||||
width = 60,
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = "rounded",
|
||||
width = 60,
|
||||
})
|
||||
end
|
||||
|
||||
local function lsp_highlight_document(client)
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
local status_ok, illuminate = pcall(require, "illuminate")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
illuminate.on_attach(client)
|
||||
-- end
|
||||
end
|
||||
|
||||
local function lsp_keymaps(bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
bufnr,
|
||||
"n",
|
||||
"gl",
|
||||
'<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>',
|
||||
opts
|
||||
)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])
|
||||
end
|
||||
|
||||
M.on_attach = function(client, bufnr)
|
||||
-- vim.notify(client.name .. " starting...")
|
||||
-- TODO: refactor this into a method that checks if string in list
|
||||
if client.name == "tsserver" then
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
end
|
||||
lsp_keymaps(bufnr)
|
||||
lsp_highlight_document(client)
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
|
||||
|
||||
return M
|
||||
@@ -1,8 +0,0 @@
|
||||
local status_ok, _ = pcall(require, "lspconfig")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
require "user.lsp.configs"
|
||||
require("user.lsp.handlers").setup()
|
||||
require "user.lsp.null-ls"
|
||||
@@ -1,23 +0,0 @@
|
||||
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
|
||||
if not null_ls_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
|
||||
local formatting = null_ls.builtins.formatting
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/code_actions
|
||||
local code_actions = null_ls.builtins.code_actions
|
||||
|
||||
null_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
|
||||
formatting.black.with({ extra_args = { "--fast" } }),
|
||||
formatting.stylua,
|
||||
--diagnostics.flake8,
|
||||
diagnostics.cppcheck,
|
||||
code_actions.refactoring
|
||||
},
|
||||
})
|
||||
@@ -1,197 +0,0 @@
|
||||
local default_schemas = nil
|
||||
local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls")
|
||||
if status_ok then
|
||||
default_schemas = jsonls_settings.get_default_schemas()
|
||||
end
|
||||
|
||||
local schemas = {
|
||||
{
|
||||
description = "TypeScript compiler configuration file",
|
||||
fileMatch = {
|
||||
"tsconfig.json",
|
||||
"tsconfig.*.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/tsconfig.json",
|
||||
},
|
||||
{
|
||||
description = "Lerna config",
|
||||
fileMatch = { "lerna.json" },
|
||||
url = "https://json.schemastore.org/lerna.json",
|
||||
},
|
||||
{
|
||||
description = "Babel configuration",
|
||||
fileMatch = {
|
||||
".babelrc.json",
|
||||
".babelrc",
|
||||
"babel.config.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/babelrc.json",
|
||||
},
|
||||
{
|
||||
description = "ESLint config",
|
||||
fileMatch = {
|
||||
".eslintrc.json",
|
||||
".eslintrc",
|
||||
},
|
||||
url = "https://json.schemastore.org/eslintrc.json",
|
||||
},
|
||||
{
|
||||
description = "Bucklescript config",
|
||||
fileMatch = { "bsconfig.json" },
|
||||
url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json",
|
||||
},
|
||||
{
|
||||
description = "Prettier config",
|
||||
fileMatch = {
|
||||
".prettierrc",
|
||||
".prettierrc.json",
|
||||
"prettier.config.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/prettierrc",
|
||||
},
|
||||
{
|
||||
description = "Vercel Now config",
|
||||
fileMatch = { "now.json" },
|
||||
url = "https://json.schemastore.org/now",
|
||||
},
|
||||
{
|
||||
description = "Stylelint config",
|
||||
fileMatch = {
|
||||
".stylelintrc",
|
||||
".stylelintrc.json",
|
||||
"stylelint.config.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/stylelintrc",
|
||||
},
|
||||
{
|
||||
description = "A JSON schema for the ASP.NET LaunchSettings.json files",
|
||||
fileMatch = { "launchsettings.json" },
|
||||
url = "https://json.schemastore.org/launchsettings.json",
|
||||
},
|
||||
{
|
||||
description = "Schema for CMake Presets",
|
||||
fileMatch = {
|
||||
"CMakePresets.json",
|
||||
"CMakeUserPresets.json",
|
||||
},
|
||||
url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json",
|
||||
},
|
||||
{
|
||||
description = "Configuration file as an alternative for configuring your repository in the settings page.",
|
||||
fileMatch = {
|
||||
".codeclimate.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/codeclimate.json",
|
||||
},
|
||||
{
|
||||
description = "LLVM compilation database",
|
||||
fileMatch = {
|
||||
"compile_commands.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/compile-commands.json",
|
||||
},
|
||||
{
|
||||
description = "Config file for Command Task Runner",
|
||||
fileMatch = {
|
||||
"commands.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/commands.json",
|
||||
},
|
||||
{
|
||||
description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.",
|
||||
fileMatch = {
|
||||
"*.cf.json",
|
||||
"cloudformation.json",
|
||||
},
|
||||
url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json",
|
||||
},
|
||||
{
|
||||
description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.",
|
||||
fileMatch = {
|
||||
"serverless.template",
|
||||
"*.sam.json",
|
||||
"sam.json",
|
||||
},
|
||||
url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json",
|
||||
},
|
||||
{
|
||||
description = "Json schema for properties json file for a GitHub Workflow template",
|
||||
fileMatch = {
|
||||
".github/workflow-templates/**.properties.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/github-workflow-template-properties.json",
|
||||
},
|
||||
{
|
||||
description = "golangci-lint configuration file",
|
||||
fileMatch = {
|
||||
".golangci.toml",
|
||||
".golangci.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/golangci-lint.json",
|
||||
},
|
||||
{
|
||||
description = "JSON schema for the JSON Feed format",
|
||||
fileMatch = {
|
||||
"feed.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/feed.json",
|
||||
versions = {
|
||||
["1"] = "https://json.schemastore.org/feed-1.json",
|
||||
["1.1"] = "https://json.schemastore.org/feed.json",
|
||||
},
|
||||
},
|
||||
{
|
||||
description = "Packer template JSON configuration",
|
||||
fileMatch = {
|
||||
"packer.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/packer.json",
|
||||
},
|
||||
{
|
||||
description = "NPM configuration file",
|
||||
fileMatch = {
|
||||
"package.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/package.json",
|
||||
},
|
||||
{
|
||||
description = "JSON schema for Visual Studio component configuration files",
|
||||
fileMatch = {
|
||||
"*.vsconfig",
|
||||
},
|
||||
url = "https://json.schemastore.org/vsconfig.json",
|
||||
},
|
||||
{
|
||||
description = "Resume json",
|
||||
fileMatch = { "resume.json" },
|
||||
url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
|
||||
},
|
||||
}
|
||||
|
||||
local function extend(tab1, tab2)
|
||||
for _, value in ipairs(tab2 or {}) do
|
||||
table.insert(tab1, value)
|
||||
end
|
||||
return tab1
|
||||
end
|
||||
|
||||
local extended_schemas = extend(schemas, default_schemas)
|
||||
|
||||
local opts = {
|
||||
settings = {
|
||||
json = {
|
||||
schemas = extended_schemas,
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return opts
|
||||
@@ -1,16 +0,0 @@
|
||||
return {
|
||||
settings = {
|
||||
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
local status_ok, lualine = pcall(require, "lualine")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end
|
||||
|
||||
local diagnostics = {
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
sections = { "error", "warn" },
|
||||
symbols = { error = " ", warn = " " },
|
||||
colored = false,
|
||||
update_in_insert = false,
|
||||
always_visible = true,
|
||||
}
|
||||
|
||||
local diff = {
|
||||
"diff",
|
||||
colored = false,
|
||||
symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
|
||||
cond = hide_in_width
|
||||
}
|
||||
|
||||
local mode = {
|
||||
"mode",
|
||||
fmt = function(str)
|
||||
return "-- " .. str .. " --"
|
||||
end,
|
||||
}
|
||||
|
||||
local filetype = {
|
||||
"filetype",
|
||||
icons_enabled = false,
|
||||
icon = nil,
|
||||
}
|
||||
|
||||
local branch = {
|
||||
"branch",
|
||||
icons_enabled = true,
|
||||
icon = "",
|
||||
}
|
||||
|
||||
local location = {
|
||||
"location",
|
||||
padding = 0,
|
||||
}
|
||||
|
||||
-- cool function for progress
|
||||
local progress = function()
|
||||
local current_line = vim.fn.line(".")
|
||||
local total_lines = vim.fn.line("$")
|
||||
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
|
||||
local line_ratio = current_line / total_lines
|
||||
local index = math.ceil(line_ratio * #chars)
|
||||
return chars[index]
|
||||
end
|
||||
|
||||
local spaces = function()
|
||||
return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
|
||||
end
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "auto",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
disabled_filetypes = { "alpha", "dashboard", "NvimTree", "Outline" },
|
||||
always_divide_middle = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { branch, diagnostics },
|
||||
lualine_b = { mode },
|
||||
lualine_c = {},
|
||||
-- lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_x = { diff, spaces, "encoding", filetype },
|
||||
lualine_y = { location },
|
||||
lualine_z = { progress },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
})
|
||||
@@ -1,67 +0,0 @@
|
||||
local status_ok, nvim_tree = pcall(require, "nvim-tree")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
|
||||
if not config_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local tree_cb = nvim_tree_config.nvim_tree_callback
|
||||
|
||||
nvim_tree.setup {
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = true,
|
||||
},
|
||||
renderer = {
|
||||
root_folder_modifier = ":t",
|
||||
icons = {
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
folder = {
|
||||
arrow_open = "",
|
||||
arrow_closed = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "",
|
||||
staged = "S",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "U",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
show_on_dirs = true,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
side = "left",
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
|
||||
{ key = "h", cb = tree_cb "close_node" },
|
||||
{ key = "v", cb = tree_cb "vsplit" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
local options = {
|
||||
backup = false, -- creates a backup fil
|
||||
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
|
||||
cmdheight = 2, -- more space in the neovim command line for displaying messages
|
||||
conceallevel = 0, -- so that `` is visible in markdown files
|
||||
fileencoding = "utf-8", -- the encoding written to a file
|
||||
hlsearch = true, -- highlight all matches on previous search pattern
|
||||
ignorecase = true, -- ignore case in search patterns
|
||||
mouse = "a", -- allow the mouse to be used in neovim
|
||||
pumheight = 10, -- pop up menu height
|
||||
termguicolors = true, -- set term gui colors
|
||||
showtabline = 2, -- always show tabs
|
||||
smartcase = true, -- smart case
|
||||
smartindent = true, -- make indenting smarter again
|
||||
splitbelow = true, -- force all horizontal splits to go below current window
|
||||
splitright = true, -- force all vertical splits to go to the right of current window
|
||||
swapfile = false, -- creates a swapfile
|
||||
undofile = true, -- enable persistent undo
|
||||
updatetime = 300, -- faster completion (4000ms default)
|
||||
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
|
||||
expandtab = true, -- convert tabs to spaces
|
||||
shiftwidth = 4, -- the number of spaces inserted for each indentation
|
||||
tabstop = 4, -- insert 2 spaces for a tab
|
||||
number = true, -- set numbered lines
|
||||
relativenumber = true, -- set relative numbered lines
|
||||
numberwidth = 4, -- set number column width to 2 {default 4}
|
||||
wrap = true, -- display lines as one long line
|
||||
scrolloff = 12, -- is one of my fav
|
||||
sidescrolloff = 8,
|
||||
}
|
||||
|
||||
vim.opt.shortmess:append "c"
|
||||
|
||||
for k, v in pairs(options) do
|
||||
vim.opt[k] = v
|
||||
end
|
||||
|
||||
vim.cmd "set whichwrap+=<,>,[,],h,l"
|
||||
vim.cmd [[set iskeyword+=-]]
|
||||
vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work
|
||||
@@ -1,107 +0,0 @@
|
||||
local fn = vim.fn
|
||||
|
||||
-- Automatically install packer
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
PACKER_BOOTSTRAP = fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
install_path,
|
||||
})
|
||||
print("Installing packer close and reopen Neovim...")
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
end
|
||||
|
||||
-- Autocommand that reloads neovim whenever you save the plugins.lua file
|
||||
vim.cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerSync
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- Use a protected call so we don't error out on first use
|
||||
local status_ok, packer = pcall(require, "packer")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
--Install plugins here
|
||||
|
||||
return packer.startup(function(use)
|
||||
|
||||
-- General Libs
|
||||
use "wbthomason/packer.nvim" -- Have packer manage itself
|
||||
use "nvim-lua/popup.nvim" -- Popup API of vim in Neovim
|
||||
use "nvim-lua/plenary.nvim" -- Lua lib required by other plugins
|
||||
-- Colorschemes
|
||||
use "sainnhe/gruvbox-material"
|
||||
use {'shaunsingh/oxocarbon.nvim', run = './install.sh'}
|
||||
|
||||
--cmp plugins
|
||||
use "hrsh7th/nvim-cmp" -- The completion plugin
|
||||
use "hrsh7th/cmp-buffer" -- buffer completions
|
||||
use "hrsh7th/cmp-path" -- path completions
|
||||
use "saadparwaiz1/cmp_luasnip" -- snippet completions
|
||||
use "hrsh7th/cmp-nvim-lsp"
|
||||
use "hrsh7th/cmp-nvim-lua"
|
||||
|
||||
-- snippets
|
||||
use "L3MON4D3/LuaSnip" --snippet engine
|
||||
use "rafamadriz/friendly-snippets" -- a bunch of snippets to use
|
||||
use "honza/vim-snippets"
|
||||
|
||||
-- LSP
|
||||
use "neovim/nvim-lspconfig" -- enable LSP
|
||||
use "williamboman/nvim-lsp-installer" -- simple to use language server installer
|
||||
use "jose-elias-alvarez/null-ls.nvim" -- for formatters and linters
|
||||
|
||||
-- Telescope
|
||||
use "nvim-telescope/telescope.nvim"
|
||||
|
||||
-- TreeSitter
|
||||
use { "nvim-treesitter/nvim-treesitter" , run = "TSUpdate",}
|
||||
|
||||
-- Git Stuff
|
||||
use "lewis6991/gitsigns.nvim"
|
||||
use "f-person/git-blame.nvim"
|
||||
use "tpope/vim-fugitive"
|
||||
-- nvim-tree
|
||||
use {"kyazdani42/nvim-tree.lua",commit = "9c97e6449b0b0269bd44e1fd4857184dfa57bb4c"}
|
||||
|
||||
-- toggleterm
|
||||
use "akinsho/toggleterm.nvim"
|
||||
|
||||
-- lualine
|
||||
use "nvim-lualine/lualine.nvim"
|
||||
|
||||
--markdown
|
||||
use({ "iamcco/markdown-preview.nvim", run = "cd app && npm install", setup = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" }, })
|
||||
if PACKER_BOOTSTRAP then
|
||||
require("packer").sync()
|
||||
end
|
||||
--rust
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
|
||||
--vimwiki
|
||||
use {
|
||||
'vimwiki/vimwiki',
|
||||
config = function()
|
||||
vim.g.vimwiki_list = {
|
||||
{
|
||||
path = '~/vimwiki/',
|
||||
syntax = 'markdown',
|
||||
ext = '.md',
|
||||
}
|
||||
}
|
||||
vim.g.vimwiki_ext2syntax = {
|
||||
['.md'] = 'markdown',
|
||||
['.markdown'] = 'markdown',
|
||||
['.mdown'] = 'markdown',
|
||||
}
|
||||
end
|
||||
}
|
||||
end)
|
||||
@@ -1,12 +0,0 @@
|
||||
local rt = require("rust-tools")
|
||||
|
||||
rt.setup({
|
||||
server = {
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
})
|
||||
@@ -1,575 +0,0 @@
|
||||
local ls = require("luasnip")
|
||||
-- some shorthands...
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local l = require("luasnip.extras").lambda
|
||||
local rep = require("luasnip.extras").rep
|
||||
local p = require("luasnip.extras").partial
|
||||
local m = require("luasnip.extras").match
|
||||
local n = require("luasnip.extras").nonempty
|
||||
local dl = require("luasnip.extras").dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local types = require("luasnip.util.types")
|
||||
local conds = require("luasnip.extras.conditions")
|
||||
local conds_expand = require("luasnip.extras.conditions.expand")
|
||||
|
||||
-- If you're reading this file for the first time, best skip to around line 190
|
||||
-- where the actual snippet-definitions start.
|
||||
|
||||
-- Every unspecified option will be set to the default.
|
||||
ls.setup({
|
||||
history = true,
|
||||
-- Update more often, :h events for more info.
|
||||
update_events = "TextChanged,TextChangedI",
|
||||
-- Snippets aren't automatically removed if their text is deleted.
|
||||
-- `delete_check_events` determines on which events (:h events) a check for
|
||||
-- deleted snippets is performed.
|
||||
-- This can be especially useful when `history` is enabled.
|
||||
delete_check_events = "TextChanged",
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { "choiceNode", "Comment" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
-- treesitter-hl has 100, use something higher (default is 200).
|
||||
ext_base_prio = 300,
|
||||
-- minimal increase in priority.
|
||||
ext_prio_increase = 1,
|
||||
enable_autosnippets = true,
|
||||
-- mapping for cutting selected text so it's usable as SELECT_DEDENT,
|
||||
-- SELECT_RAW or TM_SELECTED_TEXT (mapped via xmap).
|
||||
store_selection_keys = "<Tab>",
|
||||
-- luasnip uses this function to get the currently active filetype. This
|
||||
-- is the (rather uninteresting) default, but it's possible to use
|
||||
-- eg. treesitter for getting the current filetype by setting ft_func to
|
||||
-- require("luasnip.extras.filetype_functions").from_cursor (requires
|
||||
-- `nvim-treesitter/nvim-treesitter`). This allows correctly resolving
|
||||
-- the current filetype in eg. a markdown-code block or `vim.cmd()`.
|
||||
ft_func = function()
|
||||
return vim.split(vim.bo.filetype, ".", true)
|
||||
end,
|
||||
})
|
||||
|
||||
-- args is a table, where 1 is the text in Placeholder 1, 2 the text in
|
||||
-- placeholder 2,...
|
||||
local function copy(args)
|
||||
return args[1]
|
||||
end
|
||||
|
||||
-- 'recursive' dynamic snippet. Expands to some text followed by itself.
|
||||
local rec_ls
|
||||
rec_ls = function()
|
||||
return sn(
|
||||
nil,
|
||||
c(1, {
|
||||
-- Order is important, sn(...) first would cause infinite loop of expansion.
|
||||
t(""),
|
||||
sn(nil, { t({ "", "\t\\item " }), i(1), d(2, rec_ls, {}) }),
|
||||
})
|
||||
)
|
||||
end
|
||||
|
||||
-- complicated function for dynamicNode.
|
||||
local function jdocsnip(args, _, old_state)
|
||||
-- !!! old_state is used to preserve user-input here. DON'T DO IT THAT WAY!
|
||||
-- Using a restoreNode instead is much easier.
|
||||
-- View this only as an example on how old_state functions.
|
||||
local nodes = {
|
||||
t({ "/**", " * " }),
|
||||
i(1, "A short Description"),
|
||||
t({ "", "" }),
|
||||
}
|
||||
|
||||
-- These will be merged with the snippet; that way, should the snippet be updated,
|
||||
-- some user input eg. text can be referred to in the new snippet.
|
||||
local param_nodes = {}
|
||||
|
||||
if old_state then
|
||||
nodes[2] = i(1, old_state.descr:get_text())
|
||||
end
|
||||
param_nodes.descr = nodes[2]
|
||||
|
||||
-- At least one param.
|
||||
if string.find(args[2][1], ", ") then
|
||||
vim.list_extend(nodes, { t({ " * ", "" }) })
|
||||
end
|
||||
|
||||
local insert = 2
|
||||
for indx, arg in ipairs(vim.split(args[2][1], ", ", true)) do
|
||||
-- Get actual name parameter.
|
||||
arg = vim.split(arg, " ", true)[2]
|
||||
if arg then
|
||||
local inode
|
||||
-- if there was some text in this parameter, use it as static_text for this new snippet.
|
||||
if old_state and old_state[arg] then
|
||||
inode = i(insert, old_state["arg" .. arg]:get_text())
|
||||
else
|
||||
inode = i(insert)
|
||||
end
|
||||
vim.list_extend(
|
||||
nodes,
|
||||
{ t({ " * @param " .. arg .. " " }), inode, t({ "", "" }) }
|
||||
)
|
||||
param_nodes["arg" .. arg] = inode
|
||||
|
||||
insert = insert + 1
|
||||
end
|
||||
end
|
||||
|
||||
if args[1][1] ~= "void" then
|
||||
local inode
|
||||
if old_state and old_state.ret then
|
||||
inode = i(insert, old_state.ret:get_text())
|
||||
else
|
||||
inode = i(insert)
|
||||
end
|
||||
|
||||
vim.list_extend(
|
||||
nodes,
|
||||
{ t({ " * ", " * @return " }), inode, t({ "", "" }) }
|
||||
)
|
||||
param_nodes.ret = inode
|
||||
insert = insert + 1
|
||||
end
|
||||
|
||||
if vim.tbl_count(args[3]) ~= 1 then
|
||||
local exc = string.gsub(args[3][2], " throws ", "")
|
||||
local ins
|
||||
if old_state and old_state.ex then
|
||||
ins = i(insert, old_state.ex:get_text())
|
||||
else
|
||||
ins = i(insert)
|
||||
end
|
||||
vim.list_extend(
|
||||
nodes,
|
||||
{ t({ " * ", " * @throws " .. exc .. " " }), ins, t({ "", "" }) }
|
||||
)
|
||||
param_nodes.ex = ins
|
||||
insert = insert + 1
|
||||
end
|
||||
|
||||
vim.list_extend(nodes, { t({ " */" }) })
|
||||
|
||||
local snip = sn(nil, nodes)
|
||||
-- Error on attempting overwrite.
|
||||
snip.old_state = param_nodes
|
||||
return snip
|
||||
end
|
||||
|
||||
-- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
|
||||
local function bash(_, _, command)
|
||||
local file = io.popen(command, "r")
|
||||
local res = {}
|
||||
for line in file:lines() do
|
||||
table.insert(res, line)
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
-- Returns a snippet_node wrapped around an insertNode whose initial
|
||||
-- text value is set to the current date in the desired format.
|
||||
local date_input = function(args, snip, old_state, fmt)
|
||||
local fmt = fmt or "%Y-%m-%d"
|
||||
return sn(nil, i(1, os.date(fmt)))
|
||||
end
|
||||
|
||||
-- snippets are added via ls.add_snippets(filetype, snippets[, opts]), where
|
||||
-- opts may specify the `type` of the snippets ("snippets" or "autosnippets",
|
||||
-- for snippets that should expand directly after the trigger is typed).
|
||||
--
|
||||
-- opts can also specify a key. By passing an unique key to each add_snippets, it's possible to reload snippets by
|
||||
-- re-`:luafile`ing the file in which they are defined (eg. this one).
|
||||
ls.add_snippets("all", {
|
||||
-- trigger is `fn`, second argument to snippet-constructor are the nodes to insert into the buffer on expansion.
|
||||
s("fn", {
|
||||
-- Simple static text.
|
||||
t("//Parameters: "),
|
||||
-- function, first parameter is the function, second the Placeholders
|
||||
-- whose text it gets as input.
|
||||
f(copy, 2),
|
||||
t({ "", "function " }),
|
||||
-- Placeholder/Insert.
|
||||
i(1),
|
||||
t("("),
|
||||
-- Placeholder with initial text.
|
||||
i(2, "int foo"),
|
||||
-- Linebreak
|
||||
t({ ") {", "\t" }),
|
||||
-- Last Placeholder, exit Point of the snippet.
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
s("class", {
|
||||
-- Choice: Switch between two different Nodes, first parameter is its position, second a list of nodes.
|
||||
c(1, {
|
||||
t("public "),
|
||||
t("private "),
|
||||
}),
|
||||
t("class "),
|
||||
i(2),
|
||||
t(" "),
|
||||
c(3, {
|
||||
t("{"),
|
||||
-- sn: Nested Snippet. Instead of a trigger, it has a position, just like insertNodes. !!! These don't expect a 0-node!!!!
|
||||
-- Inside Choices, Nodes don't need a position as the choice node is the one being jumped to.
|
||||
sn(nil, {
|
||||
t("extends "),
|
||||
-- restoreNode: stores and restores nodes.
|
||||
-- pass position, store-key and nodes.
|
||||
r(1, "other_class", i(1)),
|
||||
t(" {"),
|
||||
}),
|
||||
sn(nil, {
|
||||
t("implements "),
|
||||
-- no need to define the nodes for a given key a second time.
|
||||
r(1, "other_class"),
|
||||
t(" {"),
|
||||
}),
|
||||
}),
|
||||
t({ "", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
-- Alternative printf-like notation for defining snippets. It uses format
|
||||
-- string with placeholders similar to the ones used with Python's .format().
|
||||
s(
|
||||
"fmt1",
|
||||
fmt("To {title} {} {}.", {
|
||||
i(2, "Name"),
|
||||
i(3, "Surname"),
|
||||
title = c(1, { t("Mr."), t("Ms.") }),
|
||||
})
|
||||
),
|
||||
-- To escape delimiters use double them, e.g. `{}` -> `{{}}`.
|
||||
-- Multi-line format strings by default have empty first/last line removed.
|
||||
-- Indent common to all lines is also removed. Use the third `opts` argument
|
||||
-- to control this behaviour.
|
||||
s(
|
||||
"fmt2",
|
||||
fmt(
|
||||
[[
|
||||
foo({1}, {3}) {{
|
||||
return {2} * {4}
|
||||
}}
|
||||
]],
|
||||
{
|
||||
i(1, "x"),
|
||||
rep(1),
|
||||
i(2, "y"),
|
||||
rep(2),
|
||||
}
|
||||
)
|
||||
),
|
||||
-- Empty placeholders are numbered automatically starting from 1 or the last
|
||||
-- value of a numbered placeholder. Named placeholders do not affect numbering.
|
||||
s(
|
||||
"fmt3",
|
||||
fmt("{} {a} {} {1} {}", {
|
||||
t("1"),
|
||||
t("2"),
|
||||
a = t("A"),
|
||||
})
|
||||
),
|
||||
-- The delimiters can be changed from the default `{}` to something else.
|
||||
s("fmt4", fmt("foo() { return []; }", i(1, "x"), { delimiters = "[]" })),
|
||||
-- `fmta` is a convenient wrapper that uses `<>` instead of `{}`.
|
||||
s("fmt5", fmta("foo() { return <>; }", i(1, "x"))),
|
||||
-- By default all args must be used. Use strict=false to disable the check
|
||||
s(
|
||||
"fmt6",
|
||||
fmt("use {} only", { t("this"), t("not this") }, { strict = false })
|
||||
),
|
||||
-- Use a dynamicNode to interpolate the output of a
|
||||
-- function (see date_input above) into the initial
|
||||
-- value of an insertNode.
|
||||
s("novel", {
|
||||
t("It was a dark and stormy night on "),
|
||||
d(1, date_input, {}, { user_args = { "%A, %B %d of %Y" } }),
|
||||
t(" and the clocks were striking thirteen."),
|
||||
}),
|
||||
-- Parsing snippets: First parameter: Snippet-Trigger, Second: Snippet body.
|
||||
-- Placeholders are parsed into choices with 1. the placeholder text(as a snippet) and 2. an empty string.
|
||||
-- This means they are not SELECTed like in other editors/Snippet engines.
|
||||
ls.parser.parse_snippet(
|
||||
"lspsyn",
|
||||
"Wow! This ${1:Stuff} really ${2:works. ${3:Well, a bit.}}"
|
||||
),
|
||||
|
||||
-- When wordTrig is set to false, snippets may also expand inside other words.
|
||||
ls.parser.parse_snippet(
|
||||
{ trig = "te", wordTrig = false },
|
||||
"${1:cond} ? ${2:true} : ${3:false}"
|
||||
),
|
||||
|
||||
-- When regTrig is set, trig is treated like a pattern, this snippet will expand after any number.
|
||||
ls.parser.parse_snippet({ trig = "%d", regTrig = true }, "A Number!!"),
|
||||
-- Using the condition, it's possible to allow expansion only in specific cases.
|
||||
s("cond", {
|
||||
t("will only expand in c-style comments"),
|
||||
}, {
|
||||
condition = function(line_to_cursor, matched_trigger, captures)
|
||||
-- optional whitespace followed by //
|
||||
return line_to_cursor:match("%s*//")
|
||||
end,
|
||||
}),
|
||||
-- there's some built-in conditions in "luasnip.extras.conditions.expand" and "luasnip.extras.conditions.show".
|
||||
s("cond2", {
|
||||
t("will only expand at the beginning of the line"),
|
||||
}, {
|
||||
condition = conds_expand.line_begin,
|
||||
}),
|
||||
s("cond3", {
|
||||
t("will only expand at the end of the line"),
|
||||
}, {
|
||||
condition = conds_expand.line_end,
|
||||
}),
|
||||
-- on conditions some logic operators are defined
|
||||
s("cond4", {
|
||||
t("will only expand at the end and the start of the line"),
|
||||
}, {
|
||||
-- last function is just an example how to make own function objects and apply operators on them
|
||||
condition = conds_expand.line_end
|
||||
+ conds_expand.line_begin
|
||||
* conds.make_condition(function()
|
||||
return true
|
||||
end),
|
||||
}),
|
||||
-- The last entry of args passed to the user-function is the surrounding snippet.
|
||||
s(
|
||||
{ trig = "a%d", regTrig = true },
|
||||
f(function(_, snip)
|
||||
return "Triggered with " .. snip.trigger .. "."
|
||||
end, {})
|
||||
),
|
||||
-- It's possible to use capture-groups inside regex-triggers.
|
||||
s(
|
||||
{ trig = "b(%d)", regTrig = true },
|
||||
f(function(_, snip)
|
||||
return "Captured Text: " .. snip.captures[1] .. "."
|
||||
end, {})
|
||||
),
|
||||
s({ trig = "c(%d+)", regTrig = true }, {
|
||||
t("will only expand for even numbers"),
|
||||
}, {
|
||||
condition = function(line_to_cursor, matched_trigger, captures)
|
||||
return tonumber(captures[1]) % 2 == 0
|
||||
end,
|
||||
}),
|
||||
-- Use a function to execute any shell command and print its text.
|
||||
s("bash", f(bash, {}, { user_args = { "ls" } })),
|
||||
-- Short version for applying String transformations using function nodes.
|
||||
s("transform", {
|
||||
i(1, "initial text"),
|
||||
t({ "", "" }),
|
||||
-- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations.
|
||||
-- This list will be applied in order to the first node given in the second argument.
|
||||
l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1),
|
||||
}),
|
||||
|
||||
s("transform2", {
|
||||
i(1, "initial text"),
|
||||
t("::"),
|
||||
i(2, "replacement for e"),
|
||||
t({ "", "" }),
|
||||
-- Lambdas can also apply transforms USING the text of other nodes:
|
||||
l(l._1:gsub("e", l._2), { 1, 2 }),
|
||||
}),
|
||||
s({ trig = "trafo(%d+)", regTrig = true }, {
|
||||
-- env-variables and captures can also be used:
|
||||
l(l.CAPTURE1:gsub("1", l.TM_FILENAME), {}),
|
||||
}),
|
||||
-- Set store_selection_keys = "<Tab>" (for example) in your
|
||||
-- luasnip.config.setup() call to populate
|
||||
-- TM_SELECTED_TEXT/SELECT_RAW/SELECT_DEDENT.
|
||||
-- In this case: select a URL, hit Tab, then expand this snippet.
|
||||
s("link_url", {
|
||||
t('<a href="'),
|
||||
f(function(_, snip)
|
||||
-- TM_SELECTED_TEXT is a table to account for multiline-selections.
|
||||
-- In this case only the first line is inserted.
|
||||
return snip.env.TM_SELECTED_TEXT[1] or {}
|
||||
end, {}),
|
||||
t('">'),
|
||||
i(1),
|
||||
t("</a>"),
|
||||
i(0),
|
||||
}),
|
||||
-- Shorthand for repeating the text in a given node.
|
||||
s("repeat", { i(1, "text"), t({ "", "" }), rep(1) }),
|
||||
-- Directly insert the ouput from a function evaluated at runtime.
|
||||
s("part", p(os.date, "%Y")),
|
||||
-- use matchNodes (`m(argnode, condition, then, else)`) to insert text
|
||||
-- based on a pattern/function/lambda-evaluation.
|
||||
-- It's basically a shortcut for simple functionNodes:
|
||||
s("mat", {
|
||||
i(1, { "sample_text" }),
|
||||
t(": "),
|
||||
m(1, "%d", "contains a number", "no number :("),
|
||||
}),
|
||||
-- The `then`-text defaults to the first capture group/the entire
|
||||
-- match if there are none.
|
||||
s("mat2", {
|
||||
i(1, { "sample_text" }),
|
||||
t(": "),
|
||||
m(1, "[abc][abc][abc]"),
|
||||
}),
|
||||
-- It is even possible to apply gsubs' or other transformations
|
||||
-- before matching.
|
||||
s("mat3", {
|
||||
i(1, { "sample_text" }),
|
||||
t(": "),
|
||||
m(
|
||||
1,
|
||||
l._1:gsub("[123]", ""):match("%d"),
|
||||
"contains a number that isn't 1, 2 or 3!"
|
||||
),
|
||||
}),
|
||||
-- `match` also accepts a function in place of the condition, which in
|
||||
-- turn accepts the usual functionNode-args.
|
||||
-- The condition is considered true if the function returns any
|
||||
-- non-nil/false-value.
|
||||
-- If that value is a string, it is used as the `if`-text if no if is explicitly given.
|
||||
s("mat4", {
|
||||
i(1, { "sample_text" }),
|
||||
t(": "),
|
||||
m(1, function(args)
|
||||
-- args is a table of multiline-strings (as usual).
|
||||
return (#args[1][1] % 2 == 0 and args[1]) or nil
|
||||
end),
|
||||
}),
|
||||
-- The nonempty-node inserts text depending on whether the arg-node is
|
||||
-- empty.
|
||||
s("nempty", {
|
||||
i(1, "sample_text"),
|
||||
n(1, "i(1) is not empty!"),
|
||||
}),
|
||||
-- dynamic lambdas work exactly like regular lambdas, except that they
|
||||
-- don't return a textNode, but a dynamicNode containing one insertNode.
|
||||
-- This makes it easier to dynamically set preset-text for insertNodes.
|
||||
s("dl1", {
|
||||
i(1, "sample_text"),
|
||||
t({ ":", "" }),
|
||||
dl(2, l._1, 1),
|
||||
}),
|
||||
-- Obviously, it's also possible to apply transformations, just like lambdas.
|
||||
s("dl2", {
|
||||
i(1, "sample_text"),
|
||||
i(2, "sample_text_2"),
|
||||
t({ "", "" }),
|
||||
dl(3, l._1:gsub("\n", " linebreak ") .. l._2, { 1, 2 }),
|
||||
}),
|
||||
}, {
|
||||
key = "all",
|
||||
})
|
||||
|
||||
ls.add_snippets("java", {
|
||||
-- Very long example for a java class.
|
||||
s("fn", {
|
||||
d(6, jdocsnip, { 2, 4, 5 }),
|
||||
t({ "", "" }),
|
||||
c(1, {
|
||||
t("public "),
|
||||
t("private "),
|
||||
}),
|
||||
c(2, {
|
||||
t("void"),
|
||||
t("String"),
|
||||
t("char"),
|
||||
t("int"),
|
||||
t("double"),
|
||||
t("boolean"),
|
||||
i(nil, ""),
|
||||
}),
|
||||
t(" "),
|
||||
i(3, "myFunc"),
|
||||
t("("),
|
||||
i(4),
|
||||
t(")"),
|
||||
c(5, {
|
||||
t(""),
|
||||
sn(nil, {
|
||||
t({ "", " throws " }),
|
||||
i(1),
|
||||
}),
|
||||
}),
|
||||
t({ " {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
}, {
|
||||
key = "java",
|
||||
})
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
-- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many
|
||||
-- \item as necessary by utilizing a choiceNode.
|
||||
s("ls", {
|
||||
t({ "\\begin{itemize}", "\t\\item " }),
|
||||
i(1),
|
||||
d(2, rec_ls, {}),
|
||||
t({ "", "\\end{itemize}" }),
|
||||
}),
|
||||
}, {
|
||||
key = "tex",
|
||||
})
|
||||
|
||||
-- set type to "autosnippets" for adding autotriggered snippets.
|
||||
ls.add_snippets("all", {
|
||||
s("autotrigger", {
|
||||
t("autosnippet"),
|
||||
}),
|
||||
}, {
|
||||
type = "autosnippets",
|
||||
key = "all_auto",
|
||||
})
|
||||
|
||||
-- in a lua file: search lua-, then c-, then all-snippets.
|
||||
ls.filetype_extend("lua", { "c" })
|
||||
-- in a cpp file: search c-snippets, then all-snippets only (no cpp-snippets!!).
|
||||
ls.filetype_set("cpp", { "c" })
|
||||
|
||||
-- Beside defining your own snippets you can also load snippets from "vscode-like" packages
|
||||
-- that expose snippets in json files, for example <https://github.com/rafamadriz/friendly-snippets>.
|
||||
|
||||
require("luasnip.loaders.from_vscode").load({ include = { "python" } }) -- Load only python snippets
|
||||
|
||||
-- The directories will have to be structured like eg. <https://github.com/rafamadriz/friendly-snippets> (include
|
||||
-- a similar `package.json`)
|
||||
require("luasnip.loaders.from_vscode").load({ paths = { "./my-snippets" } }) -- Load snippets from my-snippets folder
|
||||
|
||||
-- You can also use lazy loading so snippets are loaded on-demand, not all at once (may interfere with lazy-loading luasnip itself).
|
||||
require("luasnip.loaders.from_vscode").lazy_load() -- You can pass { paths = "./my-snippets/"} as well
|
||||
|
||||
-- You can also use snippets in snipmate format, for example <https://github.com/honza/vim-snippets>.
|
||||
-- The usage is similar to vscode.
|
||||
|
||||
-- One peculiarity of honza/vim-snippets is that the file containing global
|
||||
-- snippets is _.snippets, so we need to tell luasnip that the filetype "_"
|
||||
-- contains global snippets:
|
||||
ls.filetype_extend("all", { "_" })
|
||||
|
||||
require("luasnip.loaders.from_snipmate").load({ include = { "c" } }) -- Load only snippets for c.
|
||||
|
||||
-- Load snippets from my-snippets folder
|
||||
-- The "." refers to the directory where of your `$MYVIMRC` (you can print it
|
||||
-- out with `:lua print(vim.env.MYVIMRC)`.
|
||||
-- NOTE: It's not always set! It isn't set for example if you call neovim with
|
||||
-- the `-u` argument like this: `nvim -u yeet.txt`.
|
||||
require("luasnip.loaders.from_snipmate").load({ path = { "./my-snippets" } })
|
||||
-- If path is not specified, luasnip will look for the `snippets` directory in rtp (for custom-snippet probably
|
||||
-- `~/.config/nvim/snippets`).
|
||||
|
||||
require("luasnip.loaders.from_snipmate").lazy_load() -- Lazy loading
|
||||
|
||||
-- see DOC.md/LUA SNIPPETS LOADER for some details.
|
||||
require("luasnip.loaders.from_lua").load({ include = { "c" } })
|
||||
require("luasnip.loaders.from_lua").lazy_load({ include = { "all", "cpp" } })
|
||||
@@ -1,96 +0,0 @@
|
||||
local status_ok, telescope = pcall(require, "telescope")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local actions = require "telescope.actions"
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
path_display = { "smart" },
|
||||
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-n>"] = actions.cycle_history_next,
|
||||
["<C-p>"] = actions.cycle_history_prev,
|
||||
|
||||
["<C-j>"] = actions.move_selection_next,
|
||||
["<C-k>"] = actions.move_selection_previous,
|
||||
|
||||
["<C-c>"] = actions.close,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
["<C-l>"] = actions.complete_tag,
|
||||
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
|
||||
},
|
||||
|
||||
n = {
|
||||
["<esc>"] = actions.close,
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
|
||||
["j"] = actions.move_selection_next,
|
||||
["k"] = actions.move_selection_previous,
|
||||
["H"] = actions.move_to_top,
|
||||
["M"] = actions.move_to_middle,
|
||||
["L"] = actions.move_to_bottom,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
["gg"] = actions.move_to_top,
|
||||
["G"] = actions.move_to_bottom,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
|
||||
["?"] = actions.which_key,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
-- Default configuration for builtin pickers goes here:
|
||||
-- picker_name = {
|
||||
-- picker_config_key = value,
|
||||
-- ...
|
||||
-- }
|
||||
-- Now the picker_config_key will be applied every time you call this
|
||||
-- builtin picker
|
||||
},
|
||||
extensions = {
|
||||
-- Your extension configuration goes here:
|
||||
-- extension_name = {
|
||||
-- extension_config_key = value,
|
||||
-- }
|
||||
-- please take a look at the readme of the extension you want to configure
|
||||
},
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
local status_ok, toggleterm = pcall(require, "toggleterm")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
toggleterm.setup({
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
shade_filetypes = {},
|
||||
shade_terminals = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
persist_size = true,
|
||||
direction = "float",
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = {noremap = true}
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
||||
end
|
||||
|
||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
configs.setup({
|
||||
ensure_installed = "all", -- one of "all" or a list of languages
|
||||
ignore_install = { "" }, -- List of parsers to ignore installing
|
||||
highlight = {
|
||||
enable = true, -- false will disable the whole extension
|
||||
disable = { "" }, -- list of language that will be disabled
|
||||
},
|
||||
autopairs = {
|
||||
enable = true,
|
||||
},
|
||||
indent = { enable = true, disable = { "" } },
|
||||
})
|
||||
14
lua/utils/reload.lua
Normal file
14
lua/utils/reload.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local M = {}
|
||||
|
||||
function M.reload()
|
||||
for name, _ in pairs(package.loaded) do
|
||||
if name:match("^core") or name:match("^plugins") or name == "init" then
|
||||
package.loaded[name] = nil
|
||||
end
|
||||
end
|
||||
dofile(vim.env.MYVIMRC)
|
||||
vim.notify("Config reloaded!", vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user