1
0

Merge branch 'main' of github.com:RokasPuzonas/neovim-config into main

This commit is contained in:
Rokas Puzonas 2023-05-11 17:31:02 +03:00
commit 8cbd95bc39
50 changed files with 939 additions and 714 deletions

View File

@ -1,8 +1,10 @@
# Neovim Config # Neovim Config
To ignore changes to local plugins file. Used for keeping computer specific configs/plugins
```shell
git update-index --assume-unchanged lua/plugins-local.lua
```
## Requirements ## Requirements
* ripgrep - for telescope * ripgrep - for telescope
* [A patched font](https://www.nerdfonts.com/) - for icons * [A patched font](https://www.nerdfonts.com/) - for icons

View File

@ -0,0 +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
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

@ -0,0 +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 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

View File

@ -1,46 +1,21 @@
local opt = require 'utils.opt'
local g = vim.g
local cmd = vim.cmd
-- Allow loading */init.lua files -- Allow loading */init.lua files
package.path = "./?/init.lua;"..package.path package.path = "./?/init.lua;"..package.path
-- Leader/local leader -- Leader/local leader
g.mapleader = [[ ]] vim.g.mapleader = [[ ]]
g.maplocalleader = [[,]] vim.g.maplocalleader = [[,]]
-- Disable some built-in plugins we don't want -- Disable some built-in plugins we don't want
local disabled_built_ins = { require("disable-builtin")
'matchit', require("highlight-yank")
'netrw', require("plugin-manager")
'netrwPlugin',
'netrwSettings',
'netrwFileHandlers',
}
for _, name in ipairs(disabled_built_ins) do
g['loaded_' .. name] = 1
end
require("plugins")
require("options") require("options")
require("bindings") require("bindings")
require("pludin-dev") require("pludin-dev")
require("add-guard") require("personal.add-guard")
require("cmacro-align") require("personal.cmacro-align")
-- Misc features
require("highlight-yank")
-- Background transparency
-- cmd [[autocmd ColorScheme * highlight Normal ctermbg=none guibg=none]]
-- cmd [[autocmd ColorScheme * highlight Folded ctermbg=none guibg=none]]
-- cmd [[autocmd ColorScheme * highlight SignColumn ctermbg=none guibg=none]]
-- cmd [[autocmd ColorScheme * highlight VertSplit ctermbg=none guibg=none]]
-- cmd [[autocmd ColorScheme * highlight StatusLineNC ctermbg=none guibg=none]]
-- cmd [[autocmd ColorScheme * highlight CursorLineNr ctermbg=none guibg=none]]
-- THEME_BEGIN -- THEME_BEGIN
cmd("colorscheme srcery") vim.cmd("colorscheme srcery")
-- THEME_END -- THEME_END

View File

@ -6,7 +6,7 @@ local silent = {silent = true}
map('n', 'Q', '<nop>') map('n', 'Q', '<nop>')
-- Save file -- Save file
map('n', '<C-s>', ':w<cr>') map('n', '<C-s>', ':w<cr>', silent)
-- Paste from register and not replace it -- Paste from register and not replace it
-- map('x', '<leader>p', '"_dP') -- map('x', '<leader>p', '"_dP')
@ -31,13 +31,6 @@ map('v', '>', '>gv')
map('n', '<C-Left>', ':tabprevious<cr>', silent) map('n', '<C-Left>', ':tabprevious<cr>', silent)
map('n', '<C-Right>', ':tabnext<cr>', silent) map('n', '<C-Right>', ':tabnext<cr>', silent)
-- Move lines up or down
map('n', '<A-j>', ':m .+1<CR>==', silent)
map('n', '<A-j>', ':m .+1<CR>==', silent)
map('n', '<A-k>', ':m .-2<CR>==', silent)
map('v', '<A-j>', ":m '>+1<CR>gv=gv", silent)
map('v', '<A-k>', ":m '<-2<CR>gv=gv", silent)
-- Move between windows easier in terminal windows -- Move between windows easier in terminal windows
function _G.set_terminal_keymaps() function _G.set_terminal_keymaps()
local opts = {buffer = 0} local opts = {buffer = 0}

View File

@ -1,3 +1,7 @@
local user = os.getenv("USER") return {
vim.g.autosource_hashdir = '/home/'..user..'/.cache/vim-autosource/hashes' 'jenterkin/vim-autosource',
config = function()
local user = os.getenv("USER")
vim.g.autosource_hashdir = '/home/'..user..'/.cache/vim-autosource/hashes'
end
}

View File

@ -1,4 +1,14 @@
local baleia = require("baleia").setup() return {
vim.api.nvim_create_user_command("BaleiaColorize", function() 'm00qek/baleia.nvim',
baleia.once(vim.api.nvim_get_current_buf()) tag = 'v1.2.0',
end, { }) 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
}

15
lua/config/based.lua Normal file
View File

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

View File

@ -1,11 +1,17 @@
local config = {} 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 if packer_plugins['nvim-ts-context-commentstring'] and packer_plugins['nvim-ts-context-commentstring'].loaded then
config.hook = function() config.hook = function()
if vim.api.nvim_buf_get_option(0, "filetype") == "vue" then if vim.api.nvim_buf_get_option(0, "filetype") == "vue" then
require("ts_context_commentstring.internal").update_commentstring() require("ts_context_commentstring.internal").update_commentstring()
end end
end
end
require("nvim_comment").setup(config)
end end
end }
require("nvim_comment").setup(config)

4
lua/config/devicons.lua Normal file
View File

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

9
lua/config/diffview.lua Normal file
View File

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

27
lua/config/dressing.lua Normal file
View File

@ -0,0 +1,27 @@
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,3 +1,9 @@
local map = require 'utils.map' return {
'tpope/vim-fugitive',
map('n', '<leader>gg', ':G<cr>', { silent = true }) config = function ()
-- TODO: Add most commonly used fugitive bindings
require("legendary").keymaps{
{"<leader>gg", ":G<cr>", description = "Open fugitive", opts = {silent = true}}
}
end
}

View File

@ -1,8 +1,22 @@
local map = require 'utils.map' return {
local silent = {silent = true} 'f-person/git-blame.nvim',
config = function ()
local silent = {silent = true}
map('n', '<leader>gm', ":GitBlameCopySHA<CR>", silent) require("legendary").keymaps{
map('n', '<leader>gj', ":GitBlameOpenCommitURL<CR>", silent) {
map('n', '<leader>gu', ":GitBlameToggle<CR>", silent) 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_enabled"] = 0
vim.g["gitblame_date_format"] = "%r"
end
}

View File

@ -1,33 +1,42 @@
local gitsigns = require 'gitsigns' return {
'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function ()
local gitsigns = require 'gitsigns'
gitsigns.setup{ gitsigns.setup{
on_attach = function(bufnr) on_attach = function(bufnr)
local function map(mode, lhs, rhs, opts) local function keymap_n(key, command, description, opts)
opts = vim.tbl_extend('force', {noremap = true, silent = true}, opts or {}) opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {})
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) return {key, command, description=description, opts=opts}
end 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
-- Navigation require("legendary").keymaps{
map('n', ']c', "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", {expr=true}) {
map('n', '[c', "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", {expr=true}) 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}),
-- Actions keymap_vn("<leader>hs", ":Gitsigns stage_hunk<CR>", "Stage hunk"),
map('n', '<leader>hs', ':Gitsigns stage_hunk<CR>') keymap_vn("<leader>hr", ":Gitsigns reset_hunk<CR>", "Reset hunk"),
map('v', '<leader>hs', ':Gitsigns stage_hunk<CR>') keymap_n("<leader>hS", "<cmd>Gitsigns stage_buffer<CR>", "Stage buffer"),
map('n', '<leader>hr', ':Gitsigns reset_hunk<CR>') keymap_n("<leader>hu", "<cmd>Gitsigns undo_stage_hunk<CR>", "Undo stage hunk"),
map('v', '<leader>hr', ':Gitsigns reset_hunk<CR>') keymap_n("<leader>hR", "<cmd>Gitsigns reset_buffer<CR>", "Reset buffer"),
map('n', '<leader>hS', '<cmd>Gitsigns stage_buffer<CR>') keymap_n("<leader>hp", "<cmd>Gitsigns preview_hunk<CR>", "Preview hunk"),
map('n', '<leader>hu', '<cmd>Gitsigns undo_stage_hunk<CR>') keymap_n('<leader>td', '<cmd>Gitsigns toggle_deleted<CR>', "Toggle deleted"),
map('n', '<leader>hR', '<cmd>Gitsigns reset_buffer<CR>')
map('n', '<leader>hp', '<cmd>Gitsigns preview_hunk<CR>')
map('n', '<leader>hb', '<cmd>lua require"gitsigns".blame_line{full=true}<CR>')
map('n', '<leader>tb', '<cmd>Gitsigns toggle_current_line_blame<CR>')
map('n', '<leader>hd', '<cmd>Gitsigns diffthis<CR>')
map('n', '<leader>hD', '<cmd>lua require"gitsigns".diffthis("~")<CR>')
map('n', '<leader>td', '<cmd>Gitsigns toggle_deleted<CR>')
-- Text object {'ih', {o=':<C-U>Gitsigns select_hunk<CR>', x=':<C-U>Gitsigns select_hunk<CR>'}, description="Select hunk" }
map('o', 'ih', ':<C-U>Gitsigns select_hunk<CR>') }
map('x', 'ih', ':<C-U>Gitsigns select_hunk<CR>') }
}
end
}
end end
} }

View File

@ -1,3 +1,12 @@
local silent = {silent=true} return {
vim.keymap.set("n", "s", "<Plug>(leap-forward-to)", silent) 'ggandor/leap.nvim',
vim.keymap.set("n", "S", "<Plug>(leap-backward-to)", silent) 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
}

12
lua/config/legendary.lua Normal file
View File

@ -0,0 +1,12 @@
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,26 +0,0 @@
local opt = require 'utils.opt'
opt('showmode', false)
vim.cmd [[
function! LightlineFilename()
let filename = expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
let modified = &modified ? ' +' : ''
return filename . modified
endfunction
]]
vim.g.lightline = {
colorscheme = vim.g.colors_name,
active = {
left = { { 'mode', 'paste' }, { 'gitbranch', 'readonly', 'filename' } }
},
component_function = {
gitbranch = 'FugitiveHead',
filename = 'LightlineFilename'
},
tabline = {
right = {}
}
}

View File

@ -87,20 +87,31 @@ end
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
function M.on_attach(client, bufnr) function M.on_attach(client, bufnr)
-- Mappings. -- Mappings.
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true, buffer = bufnr}
local function buf_set_keymap(mode, lhs, rhs) vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) end -- 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 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> -- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>')
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>')
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>')
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>')
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>')
-- Conflicts with movement between panes -- Conflicts with movement between panes
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>') -- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
@ -109,9 +120,6 @@ function M.on_attach(client, bufnr)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_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>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', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>')
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
buf_set_keymap('n', '<space>d', '<cmd>lua vim.diagnostic.open_float()<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_prev()<CR>')
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<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>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')

View File

@ -1,7 +1,6 @@
local lspconfig_config = require 'config.lspconfig' local lspconfig_config = require('config.lspconfig')
local lsp_installer = require 'nvim-lsp-installer' local lsp_installer = require('nvim-lsp-installer')
local lsp_installer_servers = require'nvim-lsp-installer.servers' local lsp_installer_servers = require('nvim-lsp-installer.servers')
local M = {}
-- local autoinstall_servers = {"sumneko_lua", "efm"} -- local autoinstall_servers = {"sumneko_lua", "efm"}
local autoinstall_servers = {"sumneko_lua"} local autoinstall_servers = {"sumneko_lua"}
@ -17,8 +16,8 @@ local capabilities = lspconfig_config.get_capabilities()
for _, server in ipairs(lsp_installer.get_installed_servers()) do for _, server in ipairs(lsp_installer.get_installed_servers()) do
local opts = { local opts = {
root_dir = function() root_dir = function()
return vim.fn.getcwd() return vim.fn.getcwd()
end, end,
init_options = lspconfig_config.get_server_init_options(server.name), init_options = lspconfig_config.get_server_init_options(server.name),
on_attach = lspconfig_config.on_attach, on_attach = lspconfig_config.on_attach,
on_init = lspconfig_config.on_init, on_init = lspconfig_config.on_init,
@ -38,5 +37,3 @@ for _, server in ipairs(lsp_installer.get_installed_servers()) do
server:setup(opts) server:setup(opts)
::continue:: ::continue::
end end
return M

View File

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

View File

@ -1,43 +1,14 @@
if vim.fn.has('nvim-0.5.1') == 1 then return {
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler 'RishabhRD/nvim-lsputils',
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler requires = 'RishabhRD/popfix',
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler config = function()
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
else vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
local bufnr = vim.api.nvim_buf_get_number(0) vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions) vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)
end end
}
vim.lsp.handlers['textDocument/references'] = function(_, _, result)
require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)
end
vim.lsp.handlers['textDocument/definition'] = function(_, method, result)
require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)
require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)
require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)
require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)
require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)
end
vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)
require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)
end
end

161
lua/config/lualine.lua Normal file
View File

@ -0,0 +1,161 @@
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
}

15
lua/config/luapad.lua Normal file
View File

@ -0,0 +1,15 @@
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,92 +1,99 @@
local ls = require("luasnip") local function config()
local capture = require("utils.capture") local ls = require("luasnip")
local s = ls.snippet local capture = require("utils.capture")
local sn = ls.snippet_node local s = ls.snippet
local fmt = require("luasnip.extras.fmt").fmt local sn = ls.snippet_node
local t = ls.text_node local fmt = require("luasnip.extras.fmt").fmt
local i = ls.insert_node local t = ls.text_node
local f = ls.function_node local i = ls.insert_node
local c = ls.choice_node local f = ls.function_node
local d = ls.dynamic_node local c = ls.choice_node
local d = ls.dynamic_node
local function getCurrentYear() local function getCurrentYear()
return os.date("%Y") return os.date("%Y")
end
local function getGitUsername()
local stdout = capture("git config user.name")
if stdout == "" then
return nil
end end
return stdout
end
ls.config.set_config { local function getGitUsername()
history = true, local stdout = capture("git config user.name")
updateevents = "TextChanged,TextChangedI", if stdout == "" then
enable_autosnippets = true return nil
} end
return stdout
vim.keymap.set({"i", "s"}, "<c-k>", function()
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end end
end, { silent = true })
vim.keymap.set({ "i", "s" }, "<c-j>", function() ls.config.set_config {
if ls.jumpable(-1) then history = true,
ls.jump(-1) updateevents = "TextChanged,TextChangedI",
end enable_autosnippets = true
end, { silent = -1 }) }
vim.keymap.set({"i"}, "<c-l>", function() vim.keymap.set({"i", "s"}, "<c-k>", function()
if ls.choice_active() then if ls.expand_or_jumpable() then
ls.change_choice(1) ls.expand_or_jump()
end end
end) end, { silent = true })
ls.add_snippets("all", { vim.keymap.set({ "i", "s" }, "<c-j>", function()
s("MIT", { if ls.jumpable(-1) then
t({"The MIT License (MIT)", "Copyright © "}), ls.jump(-1)
f(getCurrentYear, {}), end
t(" "), end, { silent = -1 })
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", { vim.keymap.set({"i"}, "<c-l>", function()
s("req", if ls.choice_active() then
fmt([[local {} = require("{}")]], { ls.change_choice(1)
f(function(module_name) end
local parts = vim.split(module_name[1][1], ".", true) end)
return (parts[#parts] or ""):gsub("-", "_")
end, { 1 }), ls.add_snippets("all", {
i(1) 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
}

11
lua/config/move.lua Normal file
View File

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

View File

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

View File

@ -1,39 +0,0 @@
local refactoring = require("refactoring")
refactoring.setup()
-- telescope refactoring helper
local function refactor(prompt_bufnr)
local content = require("telescope.actions.state").get_selected_entry(
prompt_bufnr
)
require("telescope.actions").close(prompt_bufnr)
require("refactoring").refactor(content.value)
end
-- NOTE: M is a global object
-- for the sake of simplicity in this example
-- you can extract this function and the helper above
-- and then require the file and call the extracted function
-- in the mappings below
M = {}
M.refactors = function()
local opts = require("telescope.themes").get_cursor() -- set personal telescope options
require("telescope.pickers").new(opts, {
prompt_title = "refactors",
finder = require("telescope.finders").new_table({
results = require("refactoring").get_refactors(),
}),
sorter = require("telescope.config").values.generic_sorter(opts),
attach_mappings = function(_, map)
map("i", "<CR>", refactor)
map("n", "<CR>", refactor)
return true
end
}):find()
end
vim.api.nvim_set_keymap("v", "<Leader>re", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], {noremap = true, silent = true, expr = false})
vim.api.nvim_set_keymap("v", "<Leader>rf", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], {noremap = true, silent = true, expr = false})
vim.api.nvim_set_keymap("v", "<Leader>rt", [[ <Esc><Cmd>lua M.refactors()<CR>]], {noremap = true, silent = true, expr = false})
return M

View File

@ -1,6 +0,0 @@
local map = require 'utils.map'
map('n', '<leader>rc', ':Restart<cr>', {silent = true})
vim.cmd [[command! PackerRestart exe 'Restart' | exe 'PackerCompile' | exe 'PackerSync']]

View File

@ -1,23 +0,0 @@
local map = require 'utils.map'
local g = vim.g
g['sneak#label'] = 1
-- case insensitive sneak
g['sneak#use_ic_scs'] = 1
-- immediately move to the next instance of search, if you move the cursor sneak is back to default behavior
g['sneak#s_next'] = 1
-- remap so I can use , and ; with f and t
map({'n', 'v'}, 'gS', '<plug>Sneak_;')
map({'n', 'v'}, 'gs', '<plug>Sneak_;')
-- map gS <Plug>Sneak_,
-- map gs <Plug>Sneak_;
-- highlight Sneak guifg=black guibg=#00C7DF ctermfg=black ctermbg=cyan
-- highlight SneakScope guifg=red guibg=yellow ctermfg=red ctermbg=yellow
-- Emoji prompt
g['sneak#prompt'] = '🔎'

View File

@ -1,99 +1,115 @@
local telescope = require('telescope') local telescope = require('telescope')
local map = require('utils.map')
local actions = require('telescope.actions') local actions = require('telescope.actions')
local builtin = require('telescope.builtin') local builtin = require('telescope.builtin')
local previewers = require('telescope.previewers')
local M = {}
local function sizelimit_maker(filepath, bufnr, opts)
opts = opts or {}
local size_limit = 100 * 1024 -- 100KiB
filepath = vim.fn.expand(filepath)
vim.loop.fs_stat(filepath, function(_, stat)
if not stat then return end
if stat.size > size_limit then
return
else
previewers.buffer_previewer_maker(filepath, bufnr, opts)
end
end)
end
-- Falling back to find_files if git_files can't find a .git directory -- Falling back to find_files if git_files can't find a .git directory
function M.project_files(opts) local function project_files()
local ok = pcall(builtin.git_files, opts) local opts = { prompt_title = 'Project files' }
if not ok then builtin.find_files(opts) end local ok = pcall(builtin.git_files, opts)
if not ok then builtin.find_files(opts) end
end end
function M.edit_config(_opts) local function edit_config()
return M.project_files{ return M.project_files{
cwd = "~/.config/nvim", cwd = "~/.config/nvim",
prompt_title = "Neovim config" prompt_title = "Neovim config"
} }
end end
local silent = {silent = true}
-- Search project files
map('n', '<C-p>', [[:lua require('config.telescope').project_files{ prompt_title = 'Project files' }<cr>]], silent)
-- Search files from current working directory
map('n', '<leader>p', [[:lua require('telescope.builtin').find_files()<cr>]], silent)
-- Edit neovim config
map('n', '<leader>ce', [[:lua require('config.telescope').edit_config()<cr>]], silent)
-- Find string
map('n', '<leader>fw', [[:lua require('telescope.builtin').live_grep()<cr>]], silent)
-- Change colorscheme
map('n', '<leader>cs', [[:lua require('telescope.builtin').colorscheme()<cr>]], silent)
-- See help tags
map('n', '<leader>fh', [[:lua require('telescope.builtin').help_tags()<cr>]], silent)
telescope.setup{ telescope.setup{
defaults = { defaults = {
buffer_previewer_maker = sizelimit_maker, vimgrep_arguments = {
path_display = { "shorten" }, "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, 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 = { mappings = {
i = { i = { ["<esc>"] = actions.close }
["<esc>"] = actions.close },
}
}
}, },
pickers = { pickers = {
find_files = {
theme = "dropdown",
},
marks = {
theme = "dropdown",
},
help_tags = {
theme = "dropdown",
},
oldfiles = {
theme = "dropdown",
},
git_files = {
theme = "dropdown",
},
live_grep = { live_grep = {
theme = "dropdown",
disable_coordinates = true disable_coordinates = true
}, },
colorscheme = { colorscheme = {
theme = "dropdown",
enable_preview = true enable_preview = true
} }
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown {}
}
} }
} }
telescope.load_extension("ui-select")
local fzfPlugin = packer_plugins["telescope-fzf-native.nvim"] local fzfPlugin = packer_plugins["telescope-fzf-native.nvim"]
if fzfPlugin and fzfPlugin.loaded then if fzfPlugin and fzfPlugin.loaded then
telescope.load_extension('fzf') telescope.load_extension('fzf')
end end
return M
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", function() builtin.live_grep() 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)

4
lua/config/tidy.lua Normal file
View File

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

View File

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

View File

@ -1,6 +1,12 @@
local treesitter = require("nvim-treesitter.configs") return {
'nvim-treesitter/nvim-treesitter',
run = function() require('nvim-treesitter.install').update{ with_sync = true } end,
config = function ()
local treesitter = require("nvim-treesitter.configs")
treesitter.setup{ treesitter.setup{
highlight = { enable = true }, highlight = { enable = true },
auto_install = true auto_install = true
}
end
} }

View File

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

View File

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

View File

@ -1,2 +0,0 @@
require("twilight").setup{
}

View File

@ -1,2 +0,0 @@
local g = vim.g
g['vimspector_enable_mappings']="HUMAN"

View File

@ -1,13 +0,0 @@
local map = require 'utils.map'
require("zen-mode").setup{
window = {
options = {
number = false,
relativenumber = false,
cursorline = false
}
}
}
map('n', '<leader>z', ':ZenMode<cr>')

11
lua/disable-builtin.lua Normal file
View File

@ -0,0 +1,11 @@
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

@ -117,3 +117,12 @@ if vim.g.neovide then
vim.g.neovide_scale_factor = 0.75 vim.g.neovide_scale_factor = 0.75
vim.g.neovide_hide_mouse_when_typing = true vim.g.neovide_hide_mouse_when_typing = true
end 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
})

View File

@ -1,5 +1,8 @@
local ts = vim.treesitter local ts = vim.treesitter
local query = ts.parse_query("c", "(preproc_function_def value: (preproc_arg) @macro_def)") local query = ts.parse_query("c", [[
(preproc_function_def value: (preproc_arg) @macro_def)
(preproc_def value: (preproc_arg) @macro_def)
]])
local function get_ast_root(bufnr) local function get_ast_root(bufnr)
local tree = ts.get_parser(bufnr, "c"):parse() local tree = ts.get_parser(bufnr, "c"):parse()

View File

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

88
lua/plugin-manager.lua Normal file
View File

@ -0,0 +1,88 @@
-- Register custom commands for plugin manager
vim.cmd [[command! -bang -nargs=+ -complete=customlist,v:lua.require'plugin-manager'.loader_complete PackerLoad lua require('plugin-manager').loader(<f-args>, '<bang>' == '!')]]
vim.cmd [[command! PackerInstall packadd packer.nvim | lua require('plugin-manager').install()]]
vim.cmd [[command! PackerUpdate packadd packer.nvim | lua require('plugin-manager').update()]]
vim.cmd [[command! PackerSync packadd packer.nvim | lua require('plugin-manager').sync()]]
vim.cmd [[command! PackerClean packadd packer.nvim | lua require('plugin-manager').clean()]]
vim.cmd [[command! PackerCompile source lua/plugin-manager.lua | packadd packer.nvim | lua require('plugin-manager').compile()]]
-- Bootstrap packer.nvim. If packer.nvim is not installed, install it.
local function bootstrap()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
return fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
end
local function create_custom_use(use)
return function (opts)
if type(opts) == "string" then
use(opts)
return opts
elseif type(opts) == "table" then
if opts.load_config then
local name = vim.split(opts[1], "/")[2]
if name:match("%.nvim$") then
name = name:sub(1, -6)
end
opts.config_name = name
end
if opts.config_name then
opts.config = ("require('config.%s')"):format(opts.config_name)
end
use(opts)
return opts[1]
else
error("What are you doing???")
end
end
end
local packer = nil
local function init()
-- Perform bootstrap
local packer_bootstrap = bootstrap()
-- Initialize packer
if packer == nil then
packer = require 'packer'
local util = require 'packer.util'
packer.init {
compile_path = util.join_paths(vim.fn.stdpath('config'), 'plugin', 'packer-compiled.lua'),
disable_commands = true
}
end
-- Reset plugins if already loaded
packer.reset()
-- Packer can manage itself
packer.use 'wbthomason/packer.nvim'
-- Use plugins
local use = create_custom_use(packer.use)
for _, module_name in ipairs{"plugins", "plugins-local"} do
local ok, use_plugins = pcall(require, module_name)
if ok then
assert(type(use_plugins) == "function")
use_plugins(use)
end
end
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end
local plugins = setmetatable({}, {
__index = function(_, key)
init()
return packer[key]
end
})
return plugins

2
lua/plugins-local.lua Normal file
View File

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

View File

@ -1,16 +1,87 @@
-- TODO: Add minimal plugin mode. Disables all plugins which are not super -- TODO: Add minimal plugin mode. Disables all plugins which are not super
-- important, to get better performance. -- important, to get better performance.
---@diagnostic disable-next-line: unused-local return function(use)
local function usePlugins(use, use_rocks) local function use_config(name)
-- Toggle terminal use(require(("config.%s"):format(name)))
use {'akinsho/toggleterm.nvim', tag = '*', config=[[require('config.toggleterm')]]} end
-- Colorize ANSI codes use_config "toggleterm"
use { 'm00qek/baleia.nvim', tag = 'v1.2.0', config=[[require('config.baleia')]] } 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 "fugitive"
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 {
"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"}
},
load_config = true
}
use {
"neovim/nvim-lspconfig",
config_name = "lspconfig"
}
use {
'williamboman/nvim-lsp-installer',
requires = 'neovim/nvim-lspconfig',
config_name = "lspinstaller"
}
use {
"nvim-lualine/lualine.nvim",
requires = "kyazdani42/nvim-web-devicons",
load_config = true
}
use {
'rafcamlet/nvim-luapad',
config_name = "luapad"
}
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 -- Debugger
use { 'mfussenegger/nvim-dap', config=[[require('config.dap')]]} use { "mfussenegger/nvim-dap", config_name="dap" }
use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] } use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] }
use 'simrat39/rust-tools.nvim' use 'simrat39/rust-tools.nvim'
use { use {
@ -19,40 +90,6 @@ local function usePlugins(use, use_rocks)
config=[[require('nvim-dap-virtual-text')]] config=[[require('nvim-dap-virtual-text')]]
} }
-- Git blame
use { 'f-person/git-blame.nvim', config=[[require("config.gitblame")]] }
-- Seemless pane switching betwen tmux and vim
use 'christoomey/vim-tmux-navigator'
-- UNIX commands
use 'tpope/vim-eunuch'
-- Movement utilities
use 'tpope/vim-unimpaired'
-- LSP
use {
'neovim/nvim-lspconfig',
config = [[require 'config.lspconfig']],
}
use {
'williamboman/nvim-lsp-installer',
requires = 'neovim/nvim-lspconfig',
config = [[require 'config.lspinstaller']]
}
-- LSP utils
use {"ray-x/lsp_signature.nvim", config = [[require 'config.lspsignature']]}
use {
'RishabhRD/nvim-lsputils',
config = [[require 'config.lsputils']],
requires = 'RishabhRD/popfix'
}
-- Snippets
use { 'L3MON4D3/LuaSnip', config = [[require 'config.luasnip']] }
-- Completion -- Completion
use { 'onsails/lspkind-nvim' } use { 'onsails/lspkind-nvim' }
use { use {
@ -60,9 +97,9 @@ local function usePlugins(use, use_rocks)
-- requires = 'onsails/lspkind-nvim', -- For some reason breaks with this line -- requires = 'onsails/lspkind-nvim', -- For some reason breaks with this line
requires = {'saadparwaiz1/cmp_luasnip'}, requires = {'saadparwaiz1/cmp_luasnip'},
after = 'lspkind-nvim', after = 'lspkind-nvim',
config = [[require 'config.cmp']] config_name = "cmp"
} }
use {'tzachar/cmp-tabnine', after = 'nvim-cmp', run='./install.sh', requires = 'hrsh7th/nvim-cmp', config = [[require 'config.tabnine']]} 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-lsp', requires = {'hrsh7th/nvim-cmp', 'nvim-lspconfig'}}
use {'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'} 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-buffer', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'}
@ -70,209 +107,20 @@ local function usePlugins(use, use_rocks)
use {'hrsh7th/cmp-cmdline', 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'}} use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp', requires = {'L3MON4D3/LuaSnip', 'nvim-cmp'}}
-- Better diagnostics viewer do -- Color themes
use { use 'srcery-colors/srcery-vim'
'folke/trouble.nvim', -- use 'morhetz/gruvbox'
requires = 'kyazdani42/nvim-web-devicons', -- use 'tomasr/molokai'
config = [[require 'config.trouble']] -- use 'Mangeshrex/uwu.vim'
} -- use 'ayu-theme/ayu-vim'
-- use 'sickill/vim-monokai'
-- Color themes -- use 'joshdick/onedark.vim'
use 'srcery-colors/srcery-vim' -- use 'mswift42/vim-themes'
-- use 'morhetz/gruvbox' -- use 'squarefrog/tomorrow-night.vim'
-- use 'tomasr/molokai' -- use 'fnune/base16-vim'
-- use 'Mangeshrex/uwu.vim' end
-- 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'
-- Text object target
use 'wellle/targets.vim'
-- Git integration
use { 'tpope/vim-fugitive', config = [[require 'config.fugitive']] }
use {
'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
config = [[require 'config.gitsigns']]
-- tag = 'release' -- To use the latest release
}
-- Refactoring
-- use {
-- "ThePrimeagen/refactoring.nvim",
-- requires = {
-- "nvim-lua/plenary.nvim",
-- "nvim-treesitter/nvim-treesitter"
-- },
-- disable = true,
-- config = [[require 'config.refactoring']]
-- }
-- Analyze startup time
use 'tweekmonster/startuptime.vim'
-- Status line and tab line
use { 'itchyny/lightline.vim', config = [[require 'config.lightline']]}
-- Load project specific settings from exrc
use { 'jenterkin/vim-autosource', config = [[require 'config.autosource']] }
-- Remove spaces at end of lines
use{ "mcauley-penney/tidy.nvim", config = [[require("tidy").setup()]] }
-- Training plugins -- Training plugins
-- use 'tjdevries/train.nvim' -- use 'tjdevries/train.nvim'
-- use 'ThePrimeagen/vim-be-good' -- use 'ThePrimeagen/vim-be-good'
-- Quick movement
-- use { 'justinmk/vim-sneak', config = [[require 'config.sneak']] }
use { 'unblevable/quick-scope', config = [[require 'config.quickscope']] }
use 'michaeljsmith/vim-indent-object'
use { 'ggandor/leap.nvim', config=[[require 'config.leap']]}
-- Smooth smooth scrolling
-- use { 'karb94/neoscroll.nvim', config = [[require('neoscroll').setup()]] }
use 'psliwka/vim-smoothie'
-- Commenting
use {
'terrortylor/nvim-comment',
config = [[require 'config.comment']],
requires = 'JoosepAlviste/nvim-ts-context-commentstring'
}
-- Color code colorizer
use { 'norcalli/nvim-colorizer.lua', config = [[require 'config.colorizer']] }
-- Fuzzy file finder
use {
'nvim-telescope/telescope.nvim',
config = [[require 'config.telescope']],
requires = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
'kyazdani42/nvim-web-devicons',
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}
}
}
-- Align characters vertically
use 'godlygeek/tabular'
-- Used for loading project specific code styles
use 'editorconfig/editorconfig-vim'
-- Provides mappings for working with symbols like (), {}, [], etc.
use 'tpope/vim-surround'
-- Allow repeating
use 'tpope/vim-repeat'
-- GLSL language support
use 'tikhomirov/vim-glsl'
-- Treesitter
use {
'nvim-treesitter/nvim-treesitter',
config = [[require 'config.treesitter']],
run = function() require('nvim-treesitter.install').update{ with_sync = true } end
}
use {
'nvim-treesitter/playground',
requires = 'nvim-treesitter/nvim-treesitter',
cmd = "TSPlaygroundToggle"
}
-- Dev icons
use {'kyazdani42/nvim-web-devicons', config = [[require('nvim-web-devicons').setup()]]}
-- Zen mode
use { 'folke/zen-mode.nvim', config = [[require 'config.zen-mode']] }
use {
'folke/twilight.nvim',
requires = 'folke/zen-mode.nvim',
config = [[require 'config.twilight']]
}
-- File browser
use {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = [[require 'config.nvim-tree']]
}
-- use {
-- 'lambdalisue/fern.vim',
-- config = [[require 'config.fern']],
-- requires = {
-- 'antoinemadec/FixCursorHold.nvim',
-- 'lambdalisue/fern-hijack.vim',
-- {'lambdalisue/fern-renderer-nerdfont.vim', config = [[vim.g["fern#renderer"] = "nerdfont"]]},
-- 'lambdalisue/nerdfont.vim'
-- }
-- }
-- alternatives:
-- use 'kyazdani42/nvim-tree.lua'
-- use 'zgpio/tree.nvim'
-- use 'tpope/vim-vinegar'
end end
-- Register custom commands for plugin manager
vim.cmd [[command! -bang -nargs=+ -complete=customlist,v:lua.require'plugins'.loader_complete PackerLoad lua require('plugins').loader(<f-args>, '<bang>' == '!')]]
vim.cmd [[command! PackerInstall packadd packer.nvim | lua require('plugins').install()]]
vim.cmd [[command! PackerUpdate packadd packer.nvim | lua require('plugins').update()]]
vim.cmd [[command! PackerSync packadd packer.nvim | lua require('plugins').sync()]]
vim.cmd [[command! PackerClean packadd packer.nvim | lua require('plugins').clean()]]
vim.cmd [[command! PackerCompile source lua/plugins.lua | packadd packer.nvim | lua require('plugins').compile()]]
-- Bootstrap packer.nvim. If packer.nvim is not installed, install it.
local function bootstrap()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
return fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
end
local packer = nil
local function init()
-- Perform bootstrap
local packer_bootstrap = bootstrap()
-- Initialize packer
if packer == nil then
packer = require 'packer'
local util = require 'packer.util'
packer.init {
compile_path = util.join_paths(vim.fn.stdpath('config'), 'plugin', 'packer-compiled.lua'),
disable_commands = true
}
end
-- Reset plugins if already loaded
packer.reset()
-- Packer can manage itself
packer.use 'wbthomason/packer.nvim'
-- Use plugins
usePlugins(packer.use, packer.use_rocks)
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end
local plugins = setmetatable({}, {
__index = function(_, key)
init()
return packer[key]
end,
})
return plugins