1
0

refactor to use lazy.nvim

This commit is contained in:
Rokas Puzonas 2023-10-07 18:23:48 +03:00
parent da2cf2db63
commit 85ae713bf5
65 changed files with 1559 additions and 1703 deletions

View File

@ -1,5 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.runtime.version": "LuaJIT",
"Lua.diagnostics.globals": ["vim", "packer_plugins"]
"Lua.diagnostics.globals": ["vim", "packer_plugins"],
"diagnostics.disable": [
"missing-fields"
]
}

View File

@ -1,8 +1,8 @@
if vim.g.colors_name == "srcery" then
local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground
local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground
local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground
local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground
vim.api.nvim_set_hl(0, "FloatBorder", {bg=hard_black, fg=bright_white})
vim.api.nvim_set_hl(0, "FloatNormal", {bg=hard_black, fg=bright_white})
vim.api.nvim_set_hl(0, "Pmenu", {bg=hard_black, fg=bright_white})
vim.api.nvim_set_hl(0, "FloatBorder", {bg=hard_black, fg=bright_white})
vim.api.nvim_set_hl(0, "FloatNormal", {bg=hard_black, fg=bright_white})
vim.api.nvim_set_hl(0, "Pmenu", {bg=hard_black, fg=bright_white})
end

View File

@ -1,22 +1,22 @@
if vim.g.colors_name == "srcery" then
local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground
local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground
local red = vim.api.nvim_get_hl_by_name("SrceryRed", true).foreground
local yellow = vim.api.nvim_get_hl_by_name("SrceryYellow", true).foreground
local gray1 = vim.api.nvim_get_hl_by_name("SrceryXgray1", true).foreground
local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground
local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground
local red = vim.api.nvim_get_hl_by_name("SrceryRed", true).foreground
local yellow = vim.api.nvim_get_hl_by_name("SrceryYellow", true).foreground
local gray1 = vim.api.nvim_get_hl_by_name("SrceryXgray1", true).foreground
local TelescopePrompt = {
TelescopeBorder = {bg = hard_black, fg = hard_black},
TelescopePromptBorder = {bg = gray1, fg = gray1},
TelescopePromptNormal = {bg = gray1},
TelescopePromptTitle = {fg = hard_black, bg = red },
TelescopePreviewTitle = {fg = hard_black, bg = yellow },
TelescopeNormal = {bg = hard_black, fg = bright_white},
TelescopeResultsNormal = {bg = hard_black, fg = bright_white},
TelescopePreviewNormal = {bg = hard_black, fg = bright_white},
TelescopeSelection = {bg = hard_black, fg = bright_white, underline = true},
}
for hl, col in pairs(TelescopePrompt) do
vim.api.nvim_set_hl(0, hl, col)
end
local TelescopePrompt = {
TelescopeBorder = {bg = hard_black, fg = hard_black},
TelescopePromptBorder = {bg = gray1, fg = gray1},
TelescopePromptNormal = {bg = gray1},
TelescopePromptTitle = {fg = hard_black, bg = red },
TelescopePreviewTitle = {fg = hard_black, bg = yellow },
TelescopeNormal = {bg = hard_black, fg = bright_white},
TelescopeResultsNormal = {bg = hard_black, fg = bright_white},
TelescopePreviewNormal = {bg = hard_black, fg = bright_white},
TelescopeSelection = {bg = hard_black, fg = bright_white, underline = true},
}
for hl, col in pairs(TelescopePrompt) do
vim.api.nvim_set_hl(0, hl, col)
end
end

940
init.lua
View File

@ -1,35 +1,921 @@
local cmd = vim.cmd
vim.g.mapleader = " "
vim.g.maplocalleader = " "
table.unpack = unpack
-- If possible use 24 Bit Colors
if vim.fn.has('termguicolors') == 1 then
vim.o.termguicolors = true
end
-- Allow loading */init.lua files
package.path = "./?/init.lua;"..package.path
-- Bootstrap lazy.nvim
do
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
end
-- Leader/local leader
vim.g.mapleader = [[ ]]
vim.g.maplocalleader = [[,]]
require("lazy").setup({
"psliwka/vim-smoothie",
"tpope/vim-unimpaired",
"tpope/vim-eunuch",
"tpope/vim-surround",
"tpope/vim-repeat",
{"christoomey/vim-tmux-navigator", lazy=false},
"michaeljsmith/vim-indent-object",
"godlygeek/tabular",
"mcauley-penney/tidy.nvim",
"editorconfig/editorconfig-vim",
"kevinhwang91/nvim-bqf",
"wellle/targets.vim",
-- Disable some built-in plugins we don't want
require("disable-builtin")
require("highlight-yank")
require("plugin-manager")
require("options")
require("bindings")
{
"krady21/compiler-explorer.nvim",
cmd = {"CECompile", "CECompileLive", "CEFormat", "CEAddLibrary", "CELoadExample", "CEOpenWebsite", "CEDeleteCache", "CEShowTooltip", "CEGotoLabel"}
},
require("personal.pludin-dev")
require("personal.add-guard")
require("personal.cmacro-align")
require("personal.uci")
{
"kdheepak/lazygit.nvim",
keys = {
{ "<leader>gg", "<cmd>LazyGit<cr>", desc = "Open lazygit" }
}
},
vim.g.python_ident = {
disable_parentheses_indenting = false,
closed_paren_align_last_line = false,
searchpair_timeout = 150,
continue = "shiftwidth()",
open_paren = "shiftwidth()",
nested_paren = "shiftwidth()"
{
"unblevable/quick-scope",
init = function ()
-- Trigger a highlight in the appropriate direction when pressing these keys:
vim.g.qs_highlight_on_keys = {"f", "F", "t", "T"}
vim.g.qs_max_chars = 150
end
},
{
"stevearc/dressing.nvim",
dependencies = {"nvim-telescope/telescope.nvim"},
opts = {
select = {
get_config = function(opts)
opts = opts or {}
local cfg = {
telescope = {
layout_config = {
-- width = 120,
-- height = 60,
width = 0.87,
height = 0.80,
},
},
}
if opts.kind == "legendary.nvim" then
cfg.telescope.sorter = require("telescope.sorters").fuzzy_with_index_bias({})
end
return cfg
end,
},
}
},
{ "tikhomirov/vim-glsl", ft="glsl" },
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim"},
opts = { signs = false }
},
-- Git related plugins
{
"f-person/git-blame.nvim",
config = function ()
vim.g["gitblame_enabled"] = 0
vim.g["gitblame_date_format"] = "%r"
end,
keys = {
{ "<leader>gh", "<cmd>GitBlameCopySHA<cr>" , desc = "[G]it blame, copy commit [h]ash" },
{ "<leader>go", "<cmd>GitBlameOpenCommit<cr>", desc = "[G]it blame, [o]pen commit" },
{ "<leader>gt", "<cmd>GitBlameToggle<cr>" , desc = "[G]it blame, [t]oggle" },
}
},
{
"trmckay/based.nvim",
keys = {
{ mode = {"n", "v"}, "<leader>b", function(...) require("based").convert(...) end, desc = "Convert [b]ase of number" }
}
},
-- Detect tabstop and shiftwidth automatically
"tpope/vim-sleuth",
-- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below.
{
-- LSP Configuration & Plugins
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ "williamboman/mason.nvim", config = true },
"williamboman/mason-lspconfig.nvim",
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require("fidget").setup({})`
{ "j-hui/fidget.nvim", tag = "legacy", opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
"folke/neodev.nvim",
},
},
{
"ray-x/lsp_signature.nvim",
opts = {
hint_enable = false,
toggle_key = nil,
handler_opts = {
border = { " ", " ", " ", " ", " ", " ", " ", " " }
}
}
},
{
-- Autocompletion
"hrsh7th/nvim-cmp",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
-- Adds LSP completion capabilities
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"onsails/lspkind-nvim",
-- Adds a number of user-friendly snippets
"rafamadriz/friendly-snippets",
},
},
-- Useful plugin to show you pending keybinds.
{ "folke/which-key.nvim", opts = {} },
{
-- Adds git related signs to the gutter, as well as utilities for managing changes
"lewis6991/gitsigns.nvim",
opts = {
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
on_attach = function()
local function keymap(mode, keybind, cmd, desc)
vim.keymap.set(mode, keybind, cmd, {desc=desc, buffer=true})
end
keymap({"v","n"}, "<leader>hs", ":Gitsigns stage_hunk<CR>", "[h]unk [s]tage")
keymap({"v","n"}, "<leader>hr", ":Gitsigns reset_hunk<CR>", "[h]unk [r]eset")
keymap("n", "<leader>hS", "<cmd>Gitsigns stage_buffer<CR>", "[h]unk [S]tage buffer")
keymap("n", "<leader>hu", "<cmd>Gitsigns undo_stage_hunk<CR>", "[h]unk [u]ndo stage")
keymap("n", "<leader>hR", "<cmd>Gitsigns reset_buffer<CR>", "[h]unk [R]eset buffer")
keymap("n", "<leader>hp", "<cmd>Gitsigns preview_hunk<CR>", "[h]unk [p]review")
keymap("n", '<leader>ht', '<cmd>Gitsigns toggle_deleted<CR>', "[h]unk [t]oggle deleted")
end
},
},
{
"nvim-treesitter/playground",
requires = "nvim-treesitter/nvim-treesitter",
cmd = "TSPlaygroundToggle"
},
{
"sindrets/diffview.nvim",
dependencies = {"nvim-lua/plenary.nvim"},
opts = {
enhanced_diff_hl = true
},
keys = {
{"<leader>gdo", "<cmd>DiffviewOpen<cr>", desc = "[g]it [d]iff [o]pen" },
{"<leader>gdc", "<cmd>DiffviewClose<cr>", desc = "[g]it [d]iff [c]pen" }
}
},
{
"vim-scripts/DoxygenToolkit.vim",
cmd = "Dox",
config = function()
vim.g.DoxygenToolkit_startCommentTag = "/// "
vim.g.DoxygenToolkit_interCommentTag = "/// "
vim.g.DoxygenToolkit_endCommentTag = ""
vim.g.DoxygenToolkit_startCommentBlock = "// "
vim.g.DoxygenToolkit_interCommentBlock = "// "
vim.g.DoxygenToolkit_endCommentBlock = ""
end
},
{
"SmiteshP/nvim-navbuddy",
dependencies = {
"neovim/nvim-lspconfig",
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim",
"nvim-telescope/telescope.nvim"
},
keys = {
{"<leader>o", "<cmd>Navbuddy<cr>", desc="Navbuddy"}
},
opts = {
window = {
border = "rounded",
size = "60%",
position = "50%",
sections = {
left = { size = "20%" },
mid = { size = "40%" },
right = { preview = "leaf" }
},
},
node_markers = { enabled = true },
use_default_mappings = true,
lsp = { auto_attach = true }
}
},
{
"m-gail/escape.nvim",
keys = {
{mode="v", "<leader>q", function(...) return require("escape").escape(...) end, desc="Escape [q]uotes"}
}
},
{
"rest-nvim/rest.nvim",
requires = { "nvim-lua/plenary.nvim" },
keys = {
{mode="n", "<leader>n", "<Plug>RestNvim", desc = "Run HTTP request under cursor"}
}
},
{
"jenterkin/vim-autosource",
config = function()
local data = vim.fn.stdpath("data")
vim.g.autosource_hashdir = data .. "/vim-autosource/hashes"
end
},
{
"fedepujol/move.nvim",
config = function()
local opts = { noremap = true, silent = true }
vim.keymap.set("v", "<S-j>", ":MoveBlock(1)<CR>", opts)
vim.keymap.set("v", "<S-k>", ":MoveBlock(-1)<CR>", opts)
end,
},
{
"srcery-colors/srcery-vim",
priority = 1000,
config = function()
vim.cmd.colorscheme("srcery")
end,
},
{
"rafcamlet/nvim-luapad",
cmd = {"Luapad", "LuaRun"},
init = function()
local pattern = "^/tmp/.*/%d+_Luapad%.lua$"
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("LuaPadFiletype", {clear=true}),
callback = function(data)
if data.file:match(pattern) then
vim.bo[data.buf].filetype = "lua.luapad"
end
end
})
end
},
-- {
-- -- Set lualine as statusline
-- "nvim-lualine/lualine.nvim",
-- -- See `:help lualine.txt`
-- opts = {
-- options = {
-- icons_enabled = false,
-- theme = "srcery",
-- component_separators = "|",
-- section_separators = "",
-- },
-- },
-- },
-- {
-- -- Add indentation guides even on blank lines
-- "lukas-reineke/indent-blankline.nvim",
-- -- Enable `lukas-reineke/indent-blankline.nvim`
-- -- See `:help indent_blankline.txt`
-- main = "ibl",
-- opts = {},
-- },
-- "gc" to comment visual regions/lines
{ "numToStr/Comment.nvim", opts = {} },
{
"norcalli/nvim-colorizer.lua",
lazy = false,
config = function()
require("colorizer").setup(
nil,
{
RGB = true,
RRGGBB = true,
names = false,
RRGGBBAA = true,
rgb_fn = true,
hsl_fn = true,
css = false,
css_fn = false,
mode = "background"
}
)
end
},
{
-- Highlight, edit, and navigate code
"nvim-treesitter/nvim-treesitter",
dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
build = ":TSUpdate",
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
keys = {
{ id = "Toggle neo tre[e]", "<leader>e", "<cmd>Neotree toggle<cr>", desc = "NeoTree" },
},
config = function()
require("neo-tree").setup({
window = {
mappings = {
["<c-v>"] = "open_vsplit",
["<c-x>"] = "open_split"
}
}
})
end
},
-- TODO: When updating throws an error
-- {
-- "m00qek/baleia.nvim",
-- tag = "v1.2.0",
-- config = function()
-- local baleia = require("baleia").setup()
-- vim.api.nvim_create_user_command("BaleiaColorize", function()
-- baleia.once(vim.api.nvim_get_current_buf())
-- end, { })
-- end,
-- keys = {
-- { id = "[A]NSI [C]olorize", "<leader>ac", "<cmd>BaleiaColorize<cr>", desc = "Colorize ANSI codes" }
-- }
-- },
-- TODO: Setup DAP
-- use { "mfussenegger/nvim-dap", config_name="dap" }
-- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] }
-- use 'simrat39/rust-tools.nvim'
-- use {
-- 'theHamsta/nvim-dap-virtual-text',
-- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"},
-- config=[[require('nvim-dap-virtual-text')]]
-- }
{
"s1n7ax/nvim-window-picker",
name = "window-picker",
event = "VeryLazy",
version = "2.*",
config = function()
require("window-picker").setup()
end
},
{
dir = "personal/cmacro-align",
config = function() require("personal.cmacro-align").load() end
},
{
dir = "personal/add-include-guard",
config = function() require("personal.add-include-guard").load() end,
cmd = "AddIncludeGuard"
},
{
dir = "personal/plugin-dev",
config = function() require("personal.plugin-dev").load() end,
},
{
dir = "personal/uci",
config = function() require("personal.uci").load() end,
ft="uci"
},
{
dir = "personal/disable-builtin",
lazy = false,
config = function() require("personal.disable-builtin").load() end,
},
{ import = "plugins" }
}, {})
-- [[ Setting options ]]
-- See `:help vim.o`
-- Enable auto reload of changed files
do
vim.o.autoread = true
-- TODO:
-- local autoreload_grp = vim.api.nvim_create_augroup("AutoReload", { clear = true })
-- vim.api.nvim_create_autocmd({"FocusGained","BufEnter","CursorHold","CursorHoldI"}, {
-- group = autoreload_grp,
-- pattern = {"*"},
-- callback = function()
-- -- TODO: Port this to lua
-- vim.cmd [[if mode() != 'c' | checktime | endif]]
-- end
-- })
-- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, {
-- group = autoreload_grp,
-- pattern = {"*"},
-- callback = function()
-- -- TODO: Port this to lua
-- vim.cmd [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]]
-- end
-- })
-- autocmd("auto-reload", {
-- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]],
-- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]]
-- }, true)
end
do
-- TODO: Use nvim API
vim.cmd.syntax("on")
vim.cmd.filetype("plugin on")
vim.g.zig_fmt_autosave = 0
-- Folding options
vim.o.foldmethod = 'indent'
vim.o.foldlevelstart = 99
-- Identation/Tab settings
local tab_size = 2
vim.bo.expandtab = true
vim.bo.smartindent = true
vim.bo.shiftwidth = tab_size
vim.bo.tabstop = tab_size
vim.bo.softtabstop = tab_size
vim.g.python_ident = {
disable_parentheses_indenting = false,
closed_paren_align_last_line = false,
searchpair_timeout = 150,
continue = "shiftwidth()",
open_paren = "shiftwidth()",
nested_paren = "shiftwidth()"
}
-- Set highlight on search
vim.o.hlsearch = false
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.incsearch = true
vim.o.inccommand = "nosplit"
-- Always keep at least 8 blank lines below the last line
vim.o.scrolloff = 8
-- Show 110 marker column
vim.o.colorcolumn = "110"
-- How whitespace characters should be displayed
vim.o.listchars = [[space:.,eol:$,tab:>-]]
-- Show current mode that you are in
vim.o.showmode = true
-- Add a bit of transparency to windows
vim.o.pumblend = 15
vim.cmd.highlight("PmenuSel blend=0") -- TODO: use nvim API
-- Keep non-visible files open
vim.o.hidden = true
-- Make line numbers default + relative numbers
vim.wo.number = true
vim.wo.relativenumber = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Skip redrawing window while executing macro
vim.o.lazyredraw = true
-- Sync clipboard between OS and Neovim.
vim.o.clipboard = 'unnamedplus'
-- Enable break indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300
-- Place splits below and to the right by default
vim.o.splitbelow = true
vim.o.splitright = true
-- By default don't wrap text
vim.o.wrap = false
-- Remove cmdline when not used
vim.o.cmdheight = 0
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- Scale neovide a bit
if vim.g.neovide then
vim.g.neovide_scale_factor = 0.75
vim.g.neovide_hide_mouse_when_typing = true
end
end
-- [[ Basic Keymaps ]]
do
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Better movement between tabs
vim.keymap.set('n', '<C-Left>', ':tabprevious<cr>', { silent = true })
vim.keymap.set('n', '<C-Right>', ':tabnext<cr>', { silent = true })
-- Better indenting
vim.keymap.set('v', '<', '<gv')
vim.keymap.set('v', '>', '>gv')
-- Save file
vim.keymap.set('n', '<C-s>', ':w<cr>', { silent = true })
-- Disable Ex mode
vim.keymap.set('n', 'Q', '<nop>')
-- Window movement
vim.keymap.set('n', '<c-h>', '<c-w>h')
vim.keymap.set('n', '<c-j>', '<c-w>j')
vim.keymap.set('n', '<c-k>', '<c-w>k')
vim.keymap.set('n', '<c-l>', '<c-w>l')
end
-- Change c file comment string
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("set-c-commentstring", { clear = true }),
pattern = {"c", "cc", "cpp", "h", "hpp"},
callback = function(data)
vim.api.nvim_buf_set_option(data.buf, "commentstring", "// %s")
end
})
-- Override `ft` for .h files to `c`
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }),
pattern = "cpp",
callback = function(data)
if data.file:match("%.h$") then
vim.api.nvim_buf_set_option(data.buf, "ft", "c")
end
end
})
-- Remove trailing whitespace
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})
-- Move between windows easier in terminal windows
function _G.set_terminal_keymaps()
local opts = {buffer = 0}
vim.keymap.set('t', '<C-w>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
-- Add abbreviation for != => ~= in lua files
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }),
pattern = "*.lua",
callback = function()
vim.api.nvim_cmd({ cmd = "abb", args = {"<buffer>", "!=", "~="}}, {})
end
})
-- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
vim.defer_fn(function()
require("nvim-treesitter.configs").setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "javascript", "typescript", "vimdoc", "vim" },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<c-space>",
node_incremental = "<c-space>",
scope_incremental = "<c-s>",
node_decremental = "<M-space>",
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
},
}
end, 0)
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
--vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
--nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
-- document existing key chains
require('which-key').register({
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
})
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. They will be passed to
-- the `settings` field of the server config. You must look up that documentation yourself.
--
-- If you want to override the default filetypes that your language server will attach to you can
-- define the property 'filetypes' to the map in question.
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
}
-- THEME_BEGIN
cmd("colorscheme srcery")
-- THEME_END
-- Setup neovim lua configuration
require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
}
end
}
-- [[ Configure nvim-cmp ]]
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}
local lspkind = require('lspkind')
lspkind.init()
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_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.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer', max_item_count = 10, keyword_length = 5 },
},
formatting = {
format = lspkind.cmp_format{ with_text = true }
},
experimental = {
native_menu = false,
ghost_text = true,
}
}
-- Use buffer source for `/`.
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et

64
lazy-lock.json Normal file
View File

@ -0,0 +1,64 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"DoxygenToolkit.vim": { "branch": "master", "commit": "afd8663d36d2ec19d26befdb10e89e912d26bbd3" },
"LuaSnip": { "branch": "master", "commit": "cdbf6f41381e5ee4810b4b09284b603d8f18365d" },
"based.nvim": { "branch": "main", "commit": "8a36e03313a07da23f06dbd803843e0646a5a70a" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"compiler-explorer.nvim": { "branch": "master", "commit": "ee8e7a2808bdad67cd2acb61b5c9ffa7735c7ec9" },
"diffview.nvim": { "branch": "main", "commit": "0437ef8bfdd67156d87140d692840a3c2824fa20" },
"dressing.nvim": { "branch": "master", "commit": "8f4d62b7817455896a3c73cab642002072c114bc" },
"editorconfig-vim": { "branch": "master", "commit": "0d54ea863089fb13be423b4aed6cca35f3a5d778" },
"escape.nvim": { "branch": "main", "commit": "dffce29f85943cc97c478c859c837df76417028a" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"git-blame.nvim": { "branch": "master", "commit": "39df33dad2cbf4eb9d17264bcda0c12e670ef1c2" },
"gitsigns.nvim": { "branch": "main", "commit": "ff01d34daaed72f271a8ffa088a7e839a60c640f" },
"lazy.nvim": { "branch": "main", "commit": "5aaafcb3019e04dd38a011b3d4c8a0f130c422ef" },
"lazygit.nvim": { "branch": "main", "commit": "de35012036d43bca03628d40d083f7c02a4cda3f" },
"lsp_signature.nvim": { "branch": "master", "commit": "bdf3dc7bb03edd25c2173e0e31c2fb122052ed23" },
"lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
"lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e2705063f395b44f676cd26596a11007a2cbd3bd" },
"mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" },
"move.nvim": { "branch": "main", "commit": "d663b74b4e38f257aae757541c9076b8047844d6" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "71f1841ba6c652908678cece623f52c1fea8a6cd" },
"neodev.nvim": { "branch": "main", "commit": "ee960afffdb95472f719a72a1edb494ffea09c92" },
"nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" },
"nvim-bqf": { "branch": "main", "commit": "8784eebf34371049b641646d00232c2603215297" },
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
"nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" },
"nvim-lspconfig": { "branch": "master", "commit": "2b361e043810d5587d9af0787f8ce40da92ec5e9" },
"nvim-luapad": { "branch": "master", "commit": "a5b3d6aa1fe5fe75e6124927392a9d3a60a0ecce" },
"nvim-navbuddy": { "branch": "master", "commit": "f137a3466a6cd1965cdcc5398daff54e66eebbe5" },
"nvim-navic": { "branch": "master", "commit": "0ffa7ffe6588f3417e680439872f5049e38a24db" },
"nvim-treesitter": { "branch": "master", "commit": "957f3f8c15a88ef0f0c77ecd13edf2e2578f176e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "a7a9ba714bcc31f5453a60d48598186b6487b75c" },
"nvim-web-devicons": { "branch": "master", "commit": "45d0237c427baba8cd05e0ab26d30e2ee58c2c82" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" },
"quick-scope": { "branch": "master", "commit": "256d81e391a22eeb53791ff62ce65f870418fa71" },
"rest.nvim": { "branch": "main", "commit": "35d949df1928b44b6d941fd9015eb3f973845b1f" },
"srcery-vim": { "branch": "master", "commit": "8ea4c4f5caf61ac4ab887fc53eabc916985db881" },
"tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" },
"targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" },
"telescope.nvim": { "branch": "master", "commit": "205f469244916716c49cc2b9026566749425c5ba" },
"tidy.nvim": { "branch": "main", "commit": "86eab24e807ed2957d26ca43b2b76b92d0fbf8f4" },
"todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" },
"vim-autosource": { "branch": "main", "commit": "569440e157d6eb37fb098dfe95252533553a56f5" },
"vim-eunuch": { "branch": "master", "commit": "67f3dd32b4dcd1c427085f42ff5f29c7adc645c6" },
"vim-glsl": { "branch": "master", "commit": "bfd330a271933c3372fcfa8ce052970746c8e9dd" },
"vim-indent-object": { "branch": "master", "commit": "5c5b24c959478929b54a9e831a8e2e651a465965" },
"vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"vim-smoothie": { "branch": "master", "commit": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" },
"vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" },
"which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" },
"window-picker": { "branch": "main", "commit": "fd5d3348b3e254ca3134f97793b4a8c702c4ad1d" }
}

View File

@ -1,52 +0,0 @@
local map = require 'utils.map'
local silent = {silent = true}
-- Disable Ex mode
map('n', 'Q', '<nop>')
-- Save file
map('n', '<C-s>', ':w<cr>', silent)
-- Paste from register and not replace it
-- map('x', '<leader>p', '"_dP')
-- Window movement
map('n', '<c-h>', '<c-w>h')
map('n', '<c-j>', '<c-w>j')
map('n', '<c-k>', '<c-w>k')
map('n', '<c-l>', '<c-w>l')
-- Resize windows
map('n', '<M-j>', ':resize -2<cr>', silent)
map('n', '<M-k>', ':resize +2<cr>', silent)
map('n', '<M-h>', ':vertical resize -2<cr>', silent)
map('n', '<M-l>', ':vertical resize +2<cr>', silent)
-- Better indenting
map('v', '<', '<gv')
map('v', '>', '>gv')
-- Better movement between tabs
map('n', '<C-Left>', ':tabprevious<cr>', silent)
map('n', '<C-Right>', ':tabnext<cr>', silent)
-- Move between windows easier in terminal windows
function _G.set_terminal_keymaps()
local opts = {buffer = 0}
vim.keymap.set('t', '<C-w>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
-- Add abbreviation for != => ~= in lua files
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }),
pattern = "*.lua",
callback = function()
vim.api.nvim_cmd({ cmd = "abb", args = {"<buffer>", "!=", "~="}}, {})
end
})

View File

@ -1,7 +0,0 @@
return {
'jenterkin/vim-autosource',
config = function()
local data = vim.fn.stdpath("data")
vim.g.autosource_hashdir = data .. '/vim-autosource/hashes'
end
}

View File

@ -1,14 +0,0 @@
return {
'm00qek/baleia.nvim',
tag = 'v1.2.0',
config = function()
local baleia = require("baleia").setup()
vim.api.nvim_create_user_command("BaleiaColorize", function()
baleia.once(vim.api.nvim_get_current_buf())
end, { })
require("legendary").command{
":BaleiaColorize", description = "Colorize ANSI codes"
}
end
}

View File

@ -1,15 +0,0 @@
return {
'trmckay/based.nvim',
config = function ()
local based = require("based")
based.setup{}
vim.keymap.set({"n", "v"}, "<C-b>", based.convert)
require("legendary").keymap{
"<C-b>",
{ n = based.convert, v = based.convert },
description = "Convert number to other base"
}
end
}

View File

@ -1,94 +0,0 @@
-- Setup nvim-cmp.
local lspkind = require('lspkind')
lspkind.init()
local cmp = require('cmp')
local luasnip = require("luasnip")
local function has_words_before()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup{
completion = { completeopt = 'menu,menuone,noinsert' },
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
['<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.Insert,
select = true,
}),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = 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 = {
{ name = 'nvim_lua' },
{ name = 'nvim_lsp', max_item_count = 20 },
{ name = 'luasnip' },
{ name = 'cmp_tabnine' },
{ name = 'path' },
{ name = 'buffer', max_item_count = 10, keyword_length = 5 },
},
formatting = {
format = lspkind.cmp_format{
with_text = true,
menu = {
buffer = "[buf]",
cmp_tabnine = "[tab9]",
nvim_lsp = "[lsp]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
}
}
},
experimental = {
native_menu = false,
ghost_text = true,
}
}
-- Use buffer source for `/`.
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':'.
-- cmp.setup.cmdline(':', {
-- sources = cmp.config.sources({
-- { name = 'path' }
-- }, {
-- { name = 'cmdline' }
-- })
-- })

View File

@ -1,19 +0,0 @@
return {
'norcalli/nvim-colorizer.lua',
config = function()
require('colorizer').setup(
nil,
{
RGB = true,
RRGGBB = true,
names = false,
RRGGBBAA = true,
rgb_fn = true,
hsl_fn = true,
css = false,
css_fn = false,
mode = 'background'
}
)
end
}

View File

@ -1,17 +0,0 @@
return {
'terrortylor/nvim-comment',
requires = 'JoosepAlviste/nvim-ts-context-commentstring',
config = function()
local config = {}
if packer_plugins['nvim-ts-context-commentstring'] and packer_plugins['nvim-ts-context-commentstring'].loaded then
config.hook = function()
if vim.api.nvim_buf_get_option(0, "filetype") == "vue" then
require("ts_context_commentstring.internal").update_commentstring()
end
end
end
require("nvim_comment").setup(config)
end
}

View File

@ -1,4 +0,0 @@
return {
'kyazdani42/nvim-web-devicons',
config = function() require('nvim-web-devicons').setup() end
}

View File

@ -1,12 +0,0 @@
return {
"sindrets/diffview.nvim",
requires = 'nvim-lua/plenary.nvim',
config = function()
require("diffview").setup{
enhanced_diff_hl = true
}
require("legendary").command{
":DiffviewOpen", description = "Open diff view"
}
end
}

View File

@ -1,11 +0,0 @@
return {
"vim-scripts/DoxygenToolkit.vim",
config = function()
vim.g.DoxygenToolkit_startCommentTag = "/// "
vim.g.DoxygenToolkit_interCommentTag = "/// "
vim.g.DoxygenToolkit_endCommentTag = ""
vim.g.DoxygenToolkit_startCommentBlock = "// "
vim.g.DoxygenToolkit_interCommentBlock = "// "
vim.g.DoxygenToolkit_endCommentBlock = ""
end
}

View File

@ -1,27 +0,0 @@
return {
"stevearc/dressing.nvim",
requires = "nvim-telescope/telescope.nvim",
config = function()
require('dressing').setup({
select = {
get_config = function(opts)
opts = opts or {}
local cfg = {
telescope = {
layout_config = {
-- width = 120,
-- height = 60,
width = 0.87,
height = 0.80,
},
},
}
if opts.kind == 'legendary.nvim' then
cfg.telescope.sorter = require('telescope.sorters').fuzzy_with_index_bias({})
end
return cfg
end,
},
})
end
}

View File

@ -1,10 +0,0 @@
return {
"m-gail/escape.nvim",
config = function()
local escape = require("escape").escape
require("legendary").keymaps{
{"<leader>e", escape, description="Escape quotes", mode={"v"}, opts={noremap=true,silent = true}}
}
end
}

View File

@ -1,26 +0,0 @@
return {
'akinsho/git-conflict.nvim',
tag = "*",
config = function()
require('git-conflict').setup{
default_mappings = false
}
require("legendary").keymaps{
{
itemgroup = "git-conflict",
description = "Git conflict",
icon = "",
keymaps = {
{ 'co', '<Plug>(git-conflict-ours)', description = "choose ours" },
{ 'ct', '<Plug>(git-conflict-theirs)', description = "choose theirs" },
{ 'cb', '<Plug>(git-conflict-both)', description = "choose both" },
{ 'c0', '<Plug>(git-conflict-none)', description = "choose none" },
{ ']x', '<Plug>(git-conflict-prev-conflict)', description = "move to previous conflict" },
{ '[x', '<Plug>(git-conflict-next-conflict)', description = "move to next conflict" },
}
}
}
end
}

View File

@ -1,22 +0,0 @@
return {
'f-person/git-blame.nvim',
config = function ()
local silent = {silent = true}
require("legendary").keymaps{
{
itemgroup = "gitblame",
description = "Git blame",
icon = "",
keymaps = {
{"<leader>gm", ":GitBlameCopySHA<CR>", description = "Copy commit hash", opts = silent},
{"<leader>gj", ":GitBlameOpenCommit<CR>", description = "Open commit", opts = silent},
{"<leader>gu", ":GitBlameToggle<CR>", description = "Toggle git blame", opts = silent},
}
}
}
vim.g["gitblame_enabled"] = 0
vim.g["gitblame_date_format"] = "%r"
end
}

View File

@ -1,42 +0,0 @@
return {
'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function ()
local gitsigns = require 'gitsigns'
gitsigns.setup{
on_attach = function(bufnr)
local function keymap_n(key, command, description, opts)
opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {})
return {key, command, description=description, opts=opts}
end
local function keymap_vn(key, command, description, opts)
opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {})
return {key, command, mode={"v", "n"}, description=description, opts=opts}
end
require("legendary").keymaps{
{
itemgroup = "githunks",
description = "Git hunks",
icon = "",
keymaps = {
keymap_n(']c', "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Jump to next hunk", {expr=true}),
keymap_n('[c', "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Jump to prev hunk", {expr=true}),
keymap_vn("<leader>hs", ":Gitsigns stage_hunk<CR>", "Stage hunk"),
keymap_vn("<leader>hr", ":Gitsigns reset_hunk<CR>", "Reset hunk"),
keymap_n("<leader>hS", "<cmd>Gitsigns stage_buffer<CR>", "Stage buffer"),
keymap_n("<leader>hu", "<cmd>Gitsigns undo_stage_hunk<CR>", "Undo stage hunk"),
keymap_n("<leader>hR", "<cmd>Gitsigns reset_buffer<CR>", "Reset buffer"),
keymap_n("<leader>hp", "<cmd>Gitsigns preview_hunk<CR>", "Preview hunk"),
keymap_n('<leader>td', '<cmd>Gitsigns toggle_deleted<CR>', "Toggle deleted"),
{'ih', {o=':<C-U>Gitsigns select_hunk<CR>', x=':<C-U>Gitsigns select_hunk<CR>'}, description="Select hunk" }
}
}
}
end
}
end
}

View File

@ -1,8 +0,0 @@
return {
'kdheepak/lazygit.nvim',
config = function ()
require("legendary").keymaps{
{"<leader>gg", ":LazyGit<cr>", description = "Open lazygit", opts = {silent = true}}
}
end
}

View File

@ -1,12 +0,0 @@
return {
'ggandor/leap.nvim',
config = function()
local silent = {silent=true}
require("legendary").keymaps{
{"s", "<Plug>(leap-forward-to)", description="Leap forward", opts=silent},
{"S", "<Plug>(leap-backward-to)", description="Leap backward", opts=silent}
}
end
}

View File

@ -1,12 +0,0 @@
return {
'mrjones2014/legendary.nvim',
requires = 'stevearc/dressing.nvim',
config = function()
require("legendary").setup{
include_legendary_cmds = false,
keymaps = {
{"<leader>l", ":Legendary<cr>", description = "Open this help menu"}
}
}
end
}

View File

@ -1,166 +0,0 @@
local cfg = {}
-- debounce_text_changes = delay, between changing something and lsp updating
cfg.flags = { debounce_text_changes = 150 }
local general_settings = { }
cfg.server_init_options = {
efm = {
documentFormatting = true
}
}
cfg.server_settings = {
efm = {
rootMarkers = {".git/"},
languages = {
lua = {
{ formatCommand = "lua-format -i", formatStdin = true }
}
},
},
jsonls = {
json = {
schemas = {
{
fileMatch = {"package.json"},
url = "https://json.schemastore.org/package.json"
},
{
fileMatch = {"tsconfig*.json"},
url = "https://json.schemastore.org/tsconfig.json"
},
}
}
},
-- "Lua.runtime.version": "LuaJIT",
-- "Lua.workspace.library": ["${3rd}/love2d/library"],
-- "Lua.workspace.checkThirdParty": false,
-- "Lua.diagnostics.disable": ["undefined-field"]
sumneko_lua = {
Lua = {
-- runtime = {
-- version = "LuaJIT"
-- },
workspace = {
checkThirdParty = false,
-- library = {"${3rd}/love2d/library"}
},
telemetry = { enable = false }
-- }
-- Lua = {
-- runtime = {
-- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
-- version = 'LuaJIT',
-- -- Setup your lua path
-- path = vim.split(package.path, ';')
-- },
-- diagnostics = {
-- -- Get the language server to recognize the `vim` global
-- globals = {'vim', 'packer_plugins'}
-- },
-- workspace = {
-- -- Make the server aware of Neovim runtime files
-- library = vim.api.nvim_get_runtime_file("", true)
-- },
}
},
rust_analyzer = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy"
}
}
},
pyright = {
python = {
pythonPath = "python3"
}
}
}
-- Apply general settings for each server
for _, settings in ipairs(cfg.server_settings) do
cfg.server_settings = vim.tbl_deep_extend("keep", settings, general_settings)
end
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
---@diagnostic disable-next-line: unused-local
function cfg.on_attach(client, bufnr)
-- Mappings.
local opts = { noremap = true, silent = true, buffer = bufnr}
-- local function keymap(mode, lhs, rhs) vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
require("legendary").keymaps{
{
itemgroup = "lsp",
description = "LSP",
keymaps = {
{'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', description = "Jump to definition", opts=opts},
{'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', description = "Jump to declaration", opts=opts},
{'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', description = "Jump to implementation", opts=opts},
{'K', '<cmd>lua vim.lsp.buf.hover()<CR>', description = "Show info", opts=opts},
{'<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', description = "Rename symbol"},
{'<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', description = "Show code actions"},
{'<space>d', '<cmd>lua vim.diagnostic.open_float()<CR>', description = "Open float"}
}
}
}
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- Conflicts with movement between panes
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
-- " auto-format
-- autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
-- autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
-- autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
end
function cfg.get_capabilities()
local capabilities = vim.lsp.protocol.make_client_capabilities()
if packer_plugins['cmp-nvim-lsp'] and packer_plugins['cmp-nvim-lsp'].loaded then
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
end
return capabilities
end
function cfg.on_init(initialize_params, config)
-- print("lsp init")
-- TODO: Load settings from ".lspconfig.json" for each projects settings
-- and merge them with the defaults
-- https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings
end
function cfg.get_server_settings(name)
return cfg.server_settings[name]
end
function cfg.get_server_init_options(name)
return cfg.server_init_options[name]
end
return cfg

View File

@ -1,18 +0,0 @@
return {
"ray-x/lsp_signature.nvim",
config = function()
local lsp_signature = require("lsp_signature")
lsp_signature.setup{
hint_enable = false,
toggle_key = nil,
handler_opts = {
border = { " ", " ", " ", " ", " ", " ", " ", " " }
}
}
-- require("legendary").keymap{
-- "<super>x", lsp_signature.toggle_float_win, description="Toggle signature float"
-- }
end
}

View File

@ -1,14 +0,0 @@
return {
'RishabhRD/nvim-lsputils',
requires = 'RishabhRD/popfix',
config = function()
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
end
}

View File

@ -1,161 +0,0 @@
local bg = vim.g.srcery_xgray1
local colors = {
red = vim.g.srcery_red,
grey = vim.g.srcery_black,
black = vim.g.srcery_hard_black,
white = vim.g.srcery_bright_white,
light_green = vim.g.srcery_bright_green,
orange = vim.g.srcery_orange,
green = vim.g.srcery_green,
}
local theme = {
normal = {
a = { fg = colors.white, bg = colors.black },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.black, bg = bg },
z = { fg = colors.white, bg = colors.black },
},
insert = { a = { fg = colors.black, bg = colors.light_green } },
visual = { a = { fg = colors.black, bg = colors.orange } },
replace = { a = { fg = colors.black, bg = colors.green } },
}
local empty = require('lualine.component'):extend()
function empty:draw(default_highlight)
self.status = ''
self.applied_separator = ''
self:apply_highlights(default_highlight)
self:apply_section_separators()
return self.status
end
-- Put proper separators and gaps between components in sections
local function process_sections(sections)
for name, section in pairs(sections) do
local left = name:sub(9, 10) < 'x'
for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do
table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } })
end
for id, comp in ipairs(section) do
if type(comp) ~= 'table' then
comp = { comp }
section[id] = comp
end
comp.separator = left and { right = '' } or { left = '' }
end
end
return sections
end
local function search_result()
local last_search = vim.fn.getreg('/')
if not last_search or last_search == '' then
return ''
end
local searchcount = vim.fn.searchcount { maxcount = 9999 }
if searchcount.total == 0 then
return ''
end
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
end
local function modified()
if vim.bo.modified then
return '+'
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
return '-'
end
return ''
end
local function recording_macro()
local reg = vim.api.nvim_call_function("reg_recording", {})
if reg ~= "" then
return "@" .. reg
else
return ""
end
end
local extensions = {"man", "quickfix"}
if pcall(require, "nvim-tree") then
table.insert(extensions, "nvim-tree")
end
if pcall(require, "toggleterm") then
table.insert(extensions, "toggleterm")
end
if pcall(require, "luapad.statusline") then
table.insert(extensions, {
sections = process_sections {
lualine_a = {'mode'},
lualine_b = {
{
'diagnostics',
source = { 'nvim' },
sections = { 'error' },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
'diagnostics',
source = { 'nvim' },
sections = { 'warn' },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ recording_macro, color = { bg = colors.orange } }
},
lualine_y = { search_result, 'filetype' },
lualine_z = { '%l:%c', '%p%%/%L' },
},
filetypes = {'lua.luapad'}
})
end
require('lualine').setup {
options = {
theme = theme,
component_separators = '',
section_separators = { left = '', right = '' },
-- ignore_focus = {"NvimTree"},
globalstatus = true
},
sections = process_sections {
lualine_a = { 'mode' },
lualine_b = {
'branch',
'diff',
{
'diagnostics',
source = { 'nvim' },
sections = { 'error' },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
'diagnostics',
source = { 'nvim' },
sections = { 'warn' },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ 'filename', file_status = false, path = 1 },
{ modified, color = { bg = colors.red } },
{ '%w', cond = function() return vim.wo.previewwindow end },
{ '%r', cond = function() return vim.bo.readonly end },
{ '%q', cond = function() return vim.bo.buftype == 'quickfix' end },
{ recording_macro, color = { bg = colors.orange } }
},
lualine_c = {},
lualine_x = {},
lualine_y = { search_result, 'filetype' },
lualine_z = { '%l:%c', '%p%%/%L' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
extensions = extensions
}

View File

@ -1,15 +0,0 @@
local pattern = "^/tmp/.*/%d+_Luapad%.lua$"
local group = vim.api.nvim_create_augroup("LuaPadFiletype", {clear=true})
vim.api.nvim_create_autocmd("FileType", {
group = group,
callback = function(data)
if data.file:match(pattern) then
vim.bo[data.buf].filetype = "lua.luapad"
end
end
})
require("legendary").commands{
{ ":Luapad", description = "Open interactive lua" },
{ ":LuaRun", description = "Run lua from current buffer" }
}

View File

@ -1,99 +0,0 @@
local function config()
local ls = require("luasnip")
local capture = require("utils.capture")
local s = ls.snippet
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
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 function getCurrentYear()
return os.date("%Y")
end
local function getGitUsername()
local stdout = capture("git config user.name")
if stdout == "" then
return nil
end
return stdout
end
ls.config.set_config {
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true
}
vim.keymap.set({"i", "s"}, "<c-k>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, { silent = true })
vim.keymap.set({ "i", "s" }, "<c-j>", function()
if ls.jumpable(-1) then
ls.jump(-1)
end
end, { silent = -1 })
vim.keymap.set({"i"}, "<c-l>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end)
ls.add_snippets("all", {
s("MIT", {
t({"The MIT License (MIT)", "Copyright © "}),
f(getCurrentYear, {}),
t(" "),
d(1, function()
return sn(nil, {
i(1, getGitUsername() or "<copyright holders>")
})
end, {}),
t{
"",
"",
"Permission is hereby granted, free of charge, to any person obtaining a copy of",
"this software and associated documentation files (the “Software”), to deal in",
"the Software without restriction, including without limitation the rights to",
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies",
"of the Software, and to permit persons to whom the Software is furnished to do",
"so, subject to the following conditions:",
"",
"The above copyright notice and this permission notice shall be included in all",
"copies or substantial portions of the Software.",
"",
"THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
"SOFTWARE.",
}
})
})
ls.add_snippets("lua", {
s("req",
fmt([[local {} = require("{}")]], {
f(function(module_name)
local parts = vim.split(module_name[1][1], ".", true)
return (parts[#parts] or ""):gsub("-", "_")
end, { 1 }),
i(1)
})
)
})
end
return {
'L3MON4D3/LuaSnip',
config = config
}

View File

@ -1,40 +0,0 @@
local lspconfig_config = require('config.lspconfig')
local function get_options(server_name)
return {
root_dir = function()
return vim.fn.getcwd()
end,
init_options = lspconfig_config.get_server_init_options(server_name),
on_attach = lspconfig_config.on_attach,
on_init = lspconfig_config.on_init,
flags = lspconfig_config.flags,
capabilities = capabilities,
settings = lspconfig_config.get_server_settings(server_name)
}
end
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-lspconfig").setup_handlers{
function (server_name) -- default handler (optional)
require("lspconfig")[server_name].setup(get_options(server_name))
end,
["rust_analyzer"] = function ()
local opts = get_options(server_name)
local has_rust_tools, rust_tools = pcall(require, "rust-tools")
if has_rust_tools then
rust_tools.setup({
server = opts,
tools = {
inlay_hints = {
auto = false
}
}
})
else
require("lspconfig")[server_name].setup(opts)
end
end
}

View File

@ -1 +0,0 @@
require("mason").setup()

View File

@ -1,11 +0,0 @@
return {
'fedepujol/move.nvim',
config = function()
local opts = { noremap = true, silent = true }
require("legendary").keymaps{
{mode='v', '<S-j>', ':MoveBlock(1)<CR>', description = "Move block up", opts=opts},
{mode='v', '<S-k>', ':MoveBlock(-1)<CR>', description = "Move block down", opts=opts},
}
end
}

View File

@ -1,33 +0,0 @@
return {
"SmiteshP/nvim-navbuddy",
requires = {
"neovim/nvim-lspconfig",
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim",
"nvim-telescope/telescope.nvim"
},
config = function()
local navbuddy = require("nvim-navbuddy")
require("legendary").keymaps{
{"<leader>o", ":Navbuddy<CR>", description="Navbuddy"}
}
navbuddy.setup {
window = {
border = "rounded",
size = "60%",
position = "50%",
sections = {
left = { size = "20%" },
mid = { size = "40%" },
right = { preview = "leaf" }
},
},
node_markers = { enabled = true },
use_default_mappings = true,
lsp = { auto_attach = true }
}
end
}

View File

@ -1,19 +0,0 @@
return {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = function ()
require("nvim-tree").setup{
git = {
enable = false
},
renderer = {
group_empty = true,
},
}
require("legendary").keymaps{
{"<leader>e", ":NvimTreeToggle<CR>", description = "Toggle file tree", {silent = true}},
{"<leader>f", ":NvimTreeFindFileToggle<CR>", description = "Show file in tree", {silent = true}}
}
end
}

View File

@ -1,9 +0,0 @@
return {
'unblevable/quick-scope',
config = function ()
-- Trigger a highlight in the appropriate direction when pressing these keys:
vim.g['qs_highlight_on_keys'] = {'f', 'F', 't', 'T'}
vim.g['qs_max_chars'] = 150
end
}

View File

@ -1,10 +0,0 @@
local tabnine = require('cmp_tabnine.config')
tabnine:setup{
max_lines = 1000,
max_num_results = 20,
sort = true,
run_on_every_keystroke = true,
snippet_placeholder = '..'
}

View File

@ -1,138 +0,0 @@
local telescope = require('telescope')
local actions = require('telescope.actions')
local builtin = require('telescope.builtin')
-- Falling back to find_files if git_files can't find a .git directory
local function project_files()
local opts = { prompt_title = 'Project files' }
local ok = pcall(builtin.git_files, opts)
if not ok then builtin.find_files(opts) end
end
local function edit_config()
return M.project_files{
cwd = "~/.config/nvim",
prompt_title = "Neovim config"
}
end
telescope.setup{
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--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" },
color_devicons = true,
winblend = 0,
border = {},
borderchars = { "", "", "", "", "", "", "", "" },
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 = {
i = { ["<esc>"] = actions.close }
},
},
pickers = {
live_grep = {
disable_coordinates = true
},
colorscheme = {
enable_preview = true
}
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown {}
}
}
}
telescope.load_extension("ui-select")
local fzfPlugin = packer_plugins["telescope-fzf-native.nvim"]
if fzfPlugin and fzfPlugin.loaded then
telescope.load_extension('fzf')
end
local function get_vtext()
local prev_regv = vim.fn.getreg('v')
vim.cmd('noau normal! "vy"')
local text = vim.fn.getreg('v')
vim.fn.setreg("v", prev_regv)
text = string.gsub(text, "\n", "")
if #text > 0 then
return text
else
return ""
end
end
local function escape_sed_symbols(text)
return text:gsub("[.()%[%]]", "\\%1")
end
local keymaps = {
-- Search project files
{ "<C-p>", project_files, description = "Open git files" },
-- Search files from current working directory
{ "<leader>p", function() builtin.find_files() end, description = "Open files" },
-- Edit neovim config
{"<leader>ce", edit_config, description = "Edit neovim config" },
-- Grep string
{ "<leader>fw", {
n = function() builtin.live_grep() end,
v = function(a)
local text = escape_sed_symbols(get_vtext())
builtin.live_grep{ default_text = text }
end
}, description = "Grep" },
-- Change colorscheme
{ "<leader>cs", function() builtin.colorscheme() end, description = "Change colorscheme" },
-- See help tags
{ "<leader>fh", function() builtin.help_tags() end, description = "Search help tags" }
}
local silent = {silent = true}
for _, keymap in ipairs(keymaps) do
keymap.opts = silent
end
require("legendary").keymaps(keymaps)

View File

@ -1,4 +0,0 @@
return {
"mcauley-penney/tidy.nvim",
config = function() require("tidy").setup() end
}

View File

@ -1,11 +0,0 @@
return {
"folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
config = function()
require("todo-comments").setup { signs = false }
require("legendary").command{
":TodoTelescope", description = "Show TODO's in telescope"
}
end
}

View File

@ -1,11 +0,0 @@
return {
'akinsho/toggleterm.nvim',
tag = '*',
config = function()
require('toggleterm').setup()
require("legendary").keymap{
"<leader>t", ":ToggleTerm<CR>", description = "Toggle terminal", opts = { silent = true }
}
end
}

View File

@ -1,15 +0,0 @@
return {
'nvim-treesitter/nvim-treesitter',
run = function() require('nvim-treesitter.install').update{ with_sync = true } end,
config = function ()
local treesitter = require("nvim-treesitter.configs")
if vim.fn.has("win32") then
require('nvim-treesitter.install').compilers = { "clang" }
end
treesitter.setup{
highlight = { enable = true },
auto_install = true
}
end
}

View File

@ -1,15 +0,0 @@
return {
'folke/trouble.nvim',
requires = 'kyazdani42/nvim-web-devicons',
config = function ()
require('trouble').setup()
local silent = {silent = true}
require("legendary").keymaps{
{'<leader>qq', ':TroubleToggle document_diagnostics<cr>', description="Toggle file diagnostics", opts=silent},
{'<leader>qf', ':TroubleToggle workspace_diagnostics<cr>', description="Toggle workspace diagnostics", opts=silent},
{'gr', ':TroubleToggle lsp_references<cr>', description="Show references in trouble", opts=silent},
}
end
}

View File

@ -1,5 +0,0 @@
return {
'nvim-treesitter/playground',
requires = 'nvim-treesitter/nvim-treesitter',
cmd = "TSPlaygroundToggle"
}

View File

@ -1,15 +0,0 @@
return {
"kevinhwang91/nvim-ufo",
requires = {"kevinhwang91/promise-async", "nvim-treesitter/nvim-treesitter"},
config = function ()
local default = {"treesitter", "indent"}
local filetypes = { c = {'indent'} }
require("ufo").setup({
provider_selector = function(bufnr, filetype, buftype)
return filetypes[filetype] or default
end
})
vim.api.nvim_set_hl(0, "UfoFoldedBg", { link = "ColorColumn" })
end
}

View File

@ -1,11 +0,0 @@
local disabled_built_ins = {
'matchit',
'netrw',
'netrwPlugin',
'netrwSettings',
'netrwFileHandlers',
}
for _, name in ipairs(disabled_built_ins) do
vim.g['loaded_' .. name] = 1
end

View File

@ -1,5 +0,0 @@
local autocmd = require 'utils.autocmd'
autocmd("highlight_yank", {
[[TextYankPost * silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=150})]]
}, true)

View File

@ -1,151 +0,0 @@
local opt = require 'utils.opt'
local autocmd = require 'utils.autocmd'
local o, wo, bo = vim.o, vim.wo, vim.bo
local cmd = vim.cmd
cmd [[syntax on]]
cmd [[filetype plugin on]]
local buffer = { o, bo }
local window = { o, wo }
-- Enable auto reload of changed files
opt('autoread', true)
autocmd("auto-reload", {
[[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]],
[[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]]
}, true)
-- List of possible completion options
opt('completeopt', 'menu,menuone,noselect')
-- Pseudo transparent popup window
opt('pumblend', 15)
cmd [[highlight PmenuSel blend=0]]
-- Don't wrap text to next line if there isin't enough space
opt('wrap', false)
-- Highlight current line
opt('cursorline', true, window)
-- Store less in shada files
opt('shada', [['20,<50,s10,h,/100]])
-- Show current mode that you are in
opt('showmode', true)
-- Keep non-visible files open
opt('hidden', true)
-- Skip redrawing window while executing macro
opt('lazyredraw', true)
-- Always use system clipboard
opt('clipboard', 'unnamedplus')
-- Amount of time after which while typing mapping will be canceled
opt('timeoutlen', 300)
-- How whitespace characters should be displayed
opt('listchars', [[space:.,eol:$,tab:>-]])
-- If possible use 24 Bit Colors
if vim.fn.has('termguicolors') == 1 then
opt('termguicolors', true)
end
-- Better Searching (Incremental searching, live replacing)
opt('ignorecase', true)
opt('smartcase', true)
opt('hlsearch', false)
opt('incsearch', true)
opt('inccommand', 'nosplit')
-- Always keep at least 8 blank lines below the last line
opt('scrolloff', 8)
opt('colorcolumn', '110')
-- Break lines
-- opt('textwidth', 80)
-- Display relative and absolute line numbers
opt('number', true, window)
opt('relativenumber', true, window)
-- Recovery
opt('undofile', true, buffer)
-- Mouse support
opt('mouse', 'nivh')
opt('mousemodel', 'extend')
-- Auto sign column
opt('signcolumn', 'auto:1', window)
-- Disable those annoying DINGS when you pressing something too much
opt('errorbells', false)
-- Always use system clipboard
opt('clipboard', 'unnamedplus')
-- Folding options
opt('foldmethod', 'indent')
opt('foldlevelstart', 99)
-- Identation/Tab settings
local tab_size = 4
opt('expandtab', false, buffer)
opt('smartindent', true, buffer)
opt('shiftwidth', tab_size, buffer)
opt('tabstop', tab_size, buffer)
opt('softtabstop', tab_size, buffer)
opt('cinkeys', '0{,0},0),0],:,!^F,o,O,e')
opt('cinoptions', 's,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#1,P0')
-- Place splits below and to the right by default
opt('splitbelow', true)
opt('splitright', true)
-- Remove cmdline when not used
opt('cmdheight', 0)
-- Scale neovide a bit
if vim.g.neovide then
vim.g.neovide_scale_factor = 0.75
vim.g.neovide_hide_mouse_when_typing = true
end
-- Change c file comment string
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("set-c-commentstring", { clear = true }),
pattern = {"c", "cc", "cpp", "h", "hpp"},
callback = function(data)
vim.api.nvim_buf_set_option(data.buf, "commentstring", "// %s")
end
})
-- Indent with spaces for vue files
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("set-vue-expandtab", { clear = true }),
pattern = "vue",
callback = function(data)
vim.api.nvim_buf_set_option(data.buf, "expandtab", true)
vim.api.nvim_buf_set_option(data.buf, 'shiftwidth', 2)
vim.api.nvim_buf_set_option(data.buf, 'tabstop', 2)
vim.api.nvim_buf_set_option(data.buf, 'softtabstop', 2)
end
})
-- Override `ft` for .h files to `c`
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }),
pattern = "cpp",
callback = function(data)
if data.file:match("%.h$") then
vim.api.nvim_buf_set_option(data.buf, "ft", "c")
end
end
})

View File

@ -1,32 +0,0 @@
vim.api.nvim_create_user_command("AddIncludeGuard", function(data)
local bufnr = vim.api.nvim_get_current_buf()
local name_pattern = data.fargs[1] or "%s_"
local function formatName(filename)
local parts = vim.split(filename, "[/\\]", {trimempty=true})
local last_part = parts[#parts]
local ext = last_part:match("%.([^%.]+)$")
local name = last_part:gsub("%.[^%.]+$", "")
if ext == "h" or ext == "hpp" then
name = name.."_H"
end
return name_pattern:format(name:upper())
end
local buf_filename = vim.api.nvim_buf_get_name(bufnr)
local guard_name = formatName(buf_filename)
vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, {
"#ifndef "..guard_name,
"#define "..guard_name,
""
})
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, {
"",
"#endif //"..guard_name
})
end, { nargs="?" })

View File

@ -0,0 +1,39 @@
local M = {}
function M.load()
-- TODO: Make it work with buffer which don't have a filename yet
vim.api.nvim_create_user_command("AddIncludeGuard", function(data)
local bufnr = vim.api.nvim_get_current_buf()
local name_pattern = data.fargs[1] or "%s_"
local function formatName(filename)
local parts = vim.split(filename, "[/\\]", {trimempty=true})
local last_part = parts[#parts]
local ext = last_part:match("%.([^%.]+)$")
local name = last_part:gsub("%.[^%.]+$", "")
if ext == "h" or ext == "hpp" then
name = name.."_H"
end
return name_pattern:format(name:upper())
end
local buf_filename = vim.api.nvim_buf_get_name(bufnr)
local guard_name = formatName(buf_filename)
vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, {
"#ifndef "..guard_name,
"#define "..guard_name,
""
})
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, {
"",
"#endif //"..guard_name
})
end, { nargs="?" })
end
return M

View File

@ -1,8 +1,6 @@
local M = {}
local ts = vim.treesitter
local query = ts.query.parse("c", [[
(preproc_function_def value: (preproc_arg) @macro_def)
(preproc_def value: (preproc_arg) @macro_def)
]])
local function get_ast_root(bufnr)
local tree = ts.get_parser(bufnr, "c"):parse()
@ -10,12 +8,29 @@ local function get_ast_root(bufnr)
end
local capture_lookup = {}
for id, name in ipairs(query.captures) do
capture_lookup[name] = id
local function do_lines_match(lines1, lines2)
if #lines1 ~= lines2 then
return false
end
for i, line1 in ipairs(lines1) do
if line1 ~= lines2[i] then
return false
end
end
return true
end
local function format_macros()
local query = ts.query.parse("c", [[
(preproc_function_def value: (preproc_arg) @macro_def)
(preproc_def value: (preproc_arg) @macro_def)
]])
local capture_lookup = {}
for id, name in ipairs(query.captures) do
capture_lookup[name] = id
end
local bufnr = vim.api.nvim_get_current_buf()
local winnr = vim.api.nvim_get_current_win()
@ -28,12 +43,14 @@ local function format_macros()
local lines = vim.api.nvim_buf_get_lines(bufnr, start_line, end_line+1, false)
local tabstop = tonumber(vim.bo[bufnr].tabstop) or 8
local new_lines = {}
for i, line in ipairs(lines) do
lines[i] = line:match("^(.-)%s*[\\]?$")
new_lines[i] = lines[i]
end
while true do
local last_line = lines[#lines]
local last_line = new_lines[#lines]
if not last_line then break end
if last_line:match("^%s*//") or last_line:match("^%s*/%*") or last_line:match("^%s*$") then
table.remove(lines, #lines)
@ -43,7 +60,7 @@ local function format_macros()
end
end
if #lines > 2 then
if #new_lines > 2 then
local line_length = 0
do
local textwidth = vim.bo[bufnr].textwidth
@ -59,30 +76,36 @@ local function format_macros()
end
if line_length <= 0 then
for _, line in ipairs(lines) do
for _, line in ipairs(new_lines) do
line_length = math.max(line_length, #line+2)
end
end
end
for i = 1, #lines-1 do
local line = lines[i]
for i = 1, #new_lines-1 do
local line = new_lines[i]
local length = #(line:gsub("\t", (" "):rep(tabstop)))
lines[i] = line .. (" "):rep(line_length - length-2) .. " \\"
end
vim.api.nvim_buf_set_lines(bufnr, start_line, end_line+1, false, lines)
if not do_lines_match(lines, new_lines) then
vim.api.nvim_buf_set_lines(bufnr, start_line, end_line+1, false, lines)
end
end
end
end
local group = vim.api.nvim_create_augroup("UpdateCMacro", { clear = true })
for _, cmd in ipairs{"InsertLeavePre", "BufWritePre"} do
vim.api.nvim_create_autocmd(cmd, {
group = group,
pattern = {"*.c", "*.h", "*.cpp", "*.hpp", "*.cc"},
callback = function (data)
format_macros()
end
})
function M.load()
local group = vim.api.nvim_create_augroup("UpdateCMacro", { clear = true })
for _, cmd in ipairs{"InsertLeavePre", "BufWritePre"} do
vim.api.nvim_create_autocmd(cmd, {
group = group,
pattern = {"*.c", "*.h", "*.cpp", "*.hpp", "*.cc"},
callback = function (data)
format_macros()
end
})
end
end
return M

View File

@ -0,0 +1,17 @@
local M = {}
function M.load()
local disabled_built_ins = {
'matchit',
'netrw',
'netrwPlugin',
'netrwSettings',
'netrwFileHandlers',
}
for _, name in ipairs(disabled_built_ins) do
vim.g['loaded_' .. name] = 1
end
end
return M

View File

@ -1,6 +0,0 @@
vim.keymap.set("n", "<leader><leader>x", ":w<cr>:source %<cr>", { silent = true })
function P(...)
print(vim.inspect(...))
end

View File

@ -0,0 +1,11 @@
local M = {}
function M.load()
vim.keymap.set("n", "<leader><leader>x", ":w<cr>:source %<cr>", { silent = true })
function _G.P(...)
print(vim.inspect(...))
end
end
return M

View File

@ -1,31 +1,39 @@
local M = {}
-- Setup tree sitter
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.uci = {
install_info = {
url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git",
files = {"src/parser.c"},
branch = "main",
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "uci",
}
function M.load()
-- Setup tree sitter
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.uci = {
install_info = {
url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git",
files = {"src/parser.c"},
branch = "main",
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "uci",
}
-- Determine UCI filetype by contents of file.
-- If file has no extension and at least one line contains the word "config"
vim.filetype.add({
pattern = {
[".*/etc/config/.*"] = "uci",
[".*/[^%.]+"] = {
priority = -math.huge,
function(_, bufnr)
for _, line in ipairs(vim.filetype.getlines(bufnr)) do
if line:find("config") ~= nil then
return "uci"
end
end
end
}
}
})
-- Determine UCI filetype by contents of file.
-- If file has no extension and at least one line contains the word "config"
-- TODO:
--[[
vim.filetype.add({
pattern = {
[".*/etc/config/.*"] = "uci",
[".*/[^%.]+"] = {
priority = -math.huge,
function(_, bufnr)
for _, line in ipairs(vim.filetype.getlines(bufnr)) do
if line:find("config") ~= nil then
return "uci"
end
end
end
}
}
})
]]--
end
return M

View File

@ -1,2 +0,0 @@
return function(use)
end

View File

@ -1,138 +0,0 @@
-- TODO: Add minimal plugin mode. Disables all plugins which are not super
-- important, to get better performance.
return function(use)
local function use_config(name)
use(require(("config.%s"):format(name)))
end
use_config "toggleterm"
use_config "baleia"
use_config "todo-comments"
use_config "dressing"
use_config "legendary"
use_config "move"
use_config "gitblame"
use_config "based"
use_config "lspsignature"
use_config "lsputils"
use_config "luasnip"
use_config "trouble"
use_config "lazygit"
use_config "gitsigns"
use_config "nvim-tree"
use_config "autosource"
use_config "tidy"
use_config "quickscope"
use_config "leap"
use_config "comment"
use_config "colorizer"
use_config "devicons"
use_config "treesitter"
use_config "ts-playground"
use_config "diffview"
use_config "git-conflict"
use_config "doxygen-tk"
use_config "navbuddy"
use_config "escape"
-- use_config "ufo"
use {
"nvim-telescope/telescope.nvim",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"kyazdani42/nvim-web-devicons",
"nvim-telescope/telescope-ui-select.nvim",
{"nvim-telescope/telescope-fzf-native.nvim", run = "make", disable = vim.fn.has("win32")}
},
load_config = true
}
use {
"williamboman/mason.nvim",
requires = 'neovim/nvim-lspconfig',
config_name = "mason"
}
use {
"williamboman/mason-lspconfig.nvim",
requires = "williamboman/mason.nvim",
config_name = "mason-lspconfig"
}
use {
"neovim/nvim-lspconfig",
requires = "williamboman/mason-lspconfig.nvim",
--config_name = "lspconfig"
}
use {
"nvim-lualine/lualine.nvim",
requires = "kyazdani42/nvim-web-devicons",
load_config = true
}
use {
'rafcamlet/nvim-luapad',
config_name = "luapad"
}
use "krady21/compiler-explorer.nvim"
use "kevinhwang91/nvim-bqf"
use "tpope/vim-eunuch"
use "christoomey/vim-tmux-navigator"
use "eandrju/cellular-automaton.nvim"
use "tweekmonster/startuptime.vim"
use "tpope/vim-unimpaired"
use "wellle/targets.vim"
use "michaeljsmith/vim-indent-object"
use "psliwka/vim-smoothie"
use "godlygeek/tabular"
use "editorconfig/editorconfig-vim"
use "tpope/vim-surround"
use "tpope/vim-repeat"
use "tikhomirov/vim-glsl"
-- Debugger
use { "mfussenegger/nvim-dap", config_name="dap" }
use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] }
use 'simrat39/rust-tools.nvim'
use {
'theHamsta/nvim-dap-virtual-text',
requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"},
config=[[require('nvim-dap-virtual-text')]]
}
-- Completion
use { 'onsails/lspkind-nvim' }
use {
'hrsh7th/nvim-cmp',
-- requires = 'onsails/lspkind-nvim', -- For some reason breaks with this line
requires = {'saadparwaiz1/cmp_luasnip'},
after = 'lspkind-nvim',
config_name = "cmp"
}
use {'tzachar/cmp-tabnine', after = 'nvim-cmp', run='./install.sh', requires = 'hrsh7th/nvim-cmp', config_name = "tabnine"}
use {'hrsh7th/cmp-nvim-lsp', requires = {'hrsh7th/nvim-cmp', 'nvim-lspconfig'}}
use {'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
use {'hrsh7th/cmp-buffer', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
use {'hrsh7th/cmp-path', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
use {'hrsh7th/cmp-cmdline', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp', requires = {'L3MON4D3/LuaSnip', 'nvim-cmp'}}
do -- Color themes
use 'srcery-colors/srcery-vim'
-- use 'morhetz/gruvbox'
-- use 'tomasr/molokai'
-- use 'Mangeshrex/uwu.vim'
-- use 'ayu-theme/ayu-vim'
-- use 'sickill/vim-monokai'
-- use 'joshdick/onedark.vim'
-- use 'mswift42/vim-themes'
-- use 'squarefrog/tomorrow-night.vim'
-- use 'fnune/base16-vim'
end
-- Training plugins
-- use 'tjdevries/train.nvim'
-- use 'ThePrimeagen/vim-be-good'
end

168
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,168 @@
local empty = require('lualine.component'):extend()
function empty:draw(default_highlight)
self.status = ''
self.applied_separator = ''
self:apply_highlights(default_highlight)
self:apply_section_separators()
return self.status
end
-- Put proper separators and gaps between components in sections
local function process_sections(sections)
local bg = vim.g.srcery_xgray1
for name, section in pairs(sections) do
local left = name:sub(9, 10) < 'x'
for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do
table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } })
end
for id, comp in ipairs(section) do
if type(comp) ~= 'table' then
comp = { comp }
section[id] = comp
end
comp.separator = left and { right = '' } or { left = '' }
end
end
return sections
end
local function search_result()
local last_search = vim.fn.getreg('/')
if not last_search or last_search == '' then
return ''
end
local searchcount = vim.fn.searchcount { maxcount = 9999 }
if searchcount.total == 0 then
return ''
end
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
end
local function recording_macro()
local reg = vim.api.nvim_call_function("reg_recording", {})
if reg ~= "" then
return "@" .. reg
else
return ""
end
end
local function modified()
if vim.bo.modified then
return '+'
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
return '-'
end
return ''
end
return {
"nvim-lualine/lualine.nvim",
dependencies = {"nvim-tree/nvim-web-devicons"},
config = function()
local bg = vim.g.srcery_xgray1
local colors = {
red = vim.g.srcery_red,
grey = vim.g.srcery_black,
black = vim.g.srcery_hard_black,
white = vim.g.srcery_bright_white,
light_green = vim.g.srcery_bright_green,
orange = vim.g.srcery_orange,
green = vim.g.srcery_green,
}
local theme = {
normal = {
a = { fg = colors.white, bg = colors.black },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.black, bg = bg },
z = { fg = colors.white, bg = colors.black },
},
insert = { a = { fg = colors.black, bg = colors.light_green } },
visual = { a = { fg = colors.black, bg = colors.orange } },
replace = { a = { fg = colors.black, bg = colors.green } },
}
local extensions = {"man", "quickfix"}
if pcall(require, "neo-tree") then
table.insert(extensions, "neo-tree")
end
if pcall(require, "luapad.statusline") then
table.insert(extensions, {
sections = process_sections {
lualine_a = {"mode"},
lualine_b = {
{
"diagnostics",
source = { "nvim" },
sections = { "error" },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
"diagnostics",
source = { "nvim" },
sections = { "warn" },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ recording_macro, color = { bg = colors.orange } }
},
lualine_y = { search_result, "filetype" },
lualine_z = { "%l:%c", "%p%%/%L" },
},
filetypes = {"lua.luapad"}
})
end
require("lualine").setup {
options = {
icons_enabled = true,
theme = theme,
component_separators = "",
section_separators = { left = "", right = "" },
globalstatus = true
},
sections = process_sections {
lualine_a = { "mode" },
lualine_b = {
"branch",
"diff",
{
"diagnostics",
source = { "nvim" },
sections = { "error" },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
"diagnostics",
source = { "nvim" },
sections = { "warn" },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ "filename", file_status = false, path = 1 },
{ modified, color = { bg = colors.red } },
{ "%w", cond = function() return vim.wo.previewwindow end },
{ "%r", cond = function() return vim.bo.readonly end },
{ "%q", cond = function() return vim.bo.buftype == "quickfix" end },
{ recording_macro, color = { bg = colors.orange } }
},
lualine_c = {},
lualine_x = {},
lualine_y = { search_result, "filetype" },
lualine_z = { "%l:%c", "%p%%/%L" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
extensions = extensions
}
end
}

89
lua/plugins/luasnip.lua Normal file
View File

@ -0,0 +1,89 @@
local function capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
return {
"L3MON4D3/LuaSnip",
config = function()
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
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 function getCurrentYear()
return os.date("%Y")
end
local function getGitUsername()
local stdout = capture("git config user.name")
if stdout == "" then return nil end
return stdout
end
ls.config.set_config {
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true
}
vim.keymap.set({"i", "s"}, "<c-k>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end, { silent = true })
vim.keymap.set({ "i", "s" }, "<c-j>", function()
if ls.jumpable(-1) then ls.jump(-1) end
end, { silent = -1 })
vim.keymap.set({"i"}, "<c-l>", function()
if ls.choice_active() then ls.change_choice(1) end
end)
ls.add_snippets("all", {
s("MIT", {
t({"The MIT License (MIT)", "Copyright © "}),
f(getCurrentYear, {}),
t(" "),
d(1, function()
return sn(nil, {
i(1, getGitUsername() or "<copyright holders>")
})
end, {}),
t{
"",
"",
"Permission is hereby granted, free of charge, to any person obtaining a copy of",
"this software and associated documentation files (the “Software”), to deal in",
"the Software without restriction, including without limitation the rights to",
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies",
"of the Software, and to permit persons to whom the Software is furnished to do",
"so, subject to the following conditions:",
"",
"The above copyright notice and this permission notice shall be included in all",
"copies or substantial portions of the Software.",
"",
"THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
"SOFTWARE.",
}
})
})
end
}

148
lua/plugins/telescope.lua Normal file
View File

@ -0,0 +1,148 @@
local telescope = require('telescope')
local actions = require('telescope.actions')
local builtin = require('telescope.builtin')
-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
-- require('telescope').setup {
-- defaults = {
-- mappings = {
-- i = {
-- ['<C-u>'] = false,
-- ['<C-d>'] = false,
-- },
-- },
-- },
-- }
-- Enable telescope fzf native, if installed
-- pcall(require('telescope').load_extension, 'fzf')
-- See `:help telescope.builtin`
-- vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
-- vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
-- vim.keymap.set('n', '<leader>/', function()
-- -- You can pass additional configuration to telescope to change theme, layout, etc.
-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
-- winblend = 10,
-- previewer = false,
-- })
-- end, { desc = '[/] Fuzzily search in current buffer' })
-- vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
-- vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
-- vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
-- vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
-- vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
-- vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
-- vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
-- Falling back to find_files if git_files can't find a .git directory
local function project_files(opts)
opts = opts or {}
if not opts.prompt_title then
opts.prompt_title = "Project files"
end
local ok = pcall(builtin.git_files, opts)
if not ok then builtin.find_files(opts) end
end
local function get_vtext()
local prev_regv = vim.fn.getreg('v')
vim.cmd('noau normal! "vy"')
local text = vim.fn.getreg('v')
vim.fn.setreg("v", prev_regv)
text = string.gsub(text, "\n", "")
if #text > 0 then
return text
else
return ""
end
end
local function escape_sed_symbols(text)
return text:gsub("[.()%[%]]", "\\%1")
end
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
"nvim-telescope/telescope-ui-select.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
cond = function() return vim.fn.executable('make') == 1 end,
}
},
config = function()
telescope.setup{
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--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" },
color_devicons = true,
winblend = 0,
border = {},
borderchars = { "", "", "", "", "", "", "", "" },
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,
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
mappings = {
i = { ["<esc>"] = actions.close }
},
},
pickers = {
live_grep = { disable_coordinates = true },
colorscheme = { enable_preview = true }
},
extensions = {
["ui-select"] = { require("telescope.themes").get_dropdown {} }
}
}
telescope.load_extension("ui-select")
pcall(telescope.load_extension, 'fzf') -- Enable telescope fzf native, if installed
local keymap = vim.keymap.set
keymap("n", "<C-p>", project_files, { desc = "Find [P]roject files" })
keymap("n", "<leader>p", function() builtin.find_files() end, { desc = "[P] Find files" })
keymap("n", "<leader>fw", function() builtin.live_grep() end, { desc = "[F]ind [W]ords" })
keymap("v", "<leader>fw", function() builtin.live_grep{ default_text = escape_sed_symbols(get_vtext()) } end, { desc = "[F]ind [W]ords" })
keymap("n", "<leader>fh", function() builtin.help_tags() end, { desc = "Find help tags" })
end
}

View File

@ -1,11 +0,0 @@
local cmd = vim.cmd
return function(group, cmds, clear)
clear = clear == nil and false or clear
if type(cmds) == 'string' then cmds = {cmds} end
cmd('augroup ' .. group)
if clear then cmd [[au!]] end
for _, c in ipairs(cmds) do cmd('autocmd ' .. c) end
cmd [[augroup END]]
end

View File

@ -1,10 +0,0 @@
return function (cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end

View File

@ -1,6 +0,0 @@
local path = ...
return {
map = require(... .. ".map"),
opt = require(... .. ".opt"),
autocmd = require(... .. ".autocmd"),
}

View File

@ -1,8 +0,0 @@
local map_key = vim.api.nvim_set_keymap
return function(modes, lhs, rhs, opts)
opts = opts or {}
opts.noremap = opts.noremap == nil and true or opts.noremap
if type(modes) == 'string' then modes = {modes} end
for _, mode in ipairs(modes) do map_key(mode, lhs, rhs, opts) end
end

View File

@ -1,6 +0,0 @@
local o_s = vim.o
return function(o, v, scopes)
scopes = scopes or {o_s}
for _, s in ipairs(scopes) do s[o] = v end
end