yes there's a bit of java in my nvim config why do you ask?
This commit is contained in:
@ -1,87 +0,0 @@
|
||||
local function auto(event, opts)
|
||||
a.nvim_create_autocmd(event, opts)
|
||||
end
|
||||
|
||||
local function augroup(name, opts)
|
||||
opts = opts or {}
|
||||
opts['clear'] = true
|
||||
a.nvim_create_augroup(name, opts)
|
||||
end
|
||||
|
||||
local winchange = augroup('winchange')
|
||||
local bufcheck = augroup('bufcheck')
|
||||
local toggles = augroup('toggles')
|
||||
|
||||
auto({ "FocusGained", "TermClose", "TermLeave" }, {
|
||||
group = bufcheck,
|
||||
desc = 'Update contents of file.',
|
||||
command = "checktime",
|
||||
})
|
||||
|
||||
auto("VimResized", {
|
||||
group = winchange,
|
||||
desc = 'Resize splits when window is resized.',
|
||||
callback = function()
|
||||
local current_tab = vim.fn.tabpagenr()
|
||||
vim.cmd("tabdo wincmd =")
|
||||
vim.cmd("tabnext " .. current_tab)
|
||||
end,
|
||||
})
|
||||
|
||||
auto('TextYankPost', {
|
||||
group = bufcheck,
|
||||
pattern = '*',
|
||||
desc = 'Highlight on yank.',
|
||||
callback = function()
|
||||
vim.highlight.on_yank{ timeout = 250 }
|
||||
end
|
||||
})
|
||||
|
||||
auto('BufRead', {
|
||||
pattern = '*',
|
||||
group = bufcheck,
|
||||
desc = 'Return to the last place the buffer was closed in.',
|
||||
callback = function() vim.cmd([[call setpos(".", getpos("'\""))]]) end
|
||||
})
|
||||
|
||||
auto('FileType', {
|
||||
pattern = { 'gitcommit', 'markdown' },
|
||||
desc = 'Spell checking and wrapping in commit buffers and markdown files.',
|
||||
callback = function()
|
||||
vim.opt_local.wrap = true
|
||||
vim.opt_local.spell = true
|
||||
end
|
||||
})
|
||||
|
||||
auto('BufWritePre', {
|
||||
pattern = '*',
|
||||
group = bufcheck,
|
||||
desc = 'Basically mkdir -p.',
|
||||
callback = function(ctx)
|
||||
if ctx.match:match("^%w%w+://") then return end
|
||||
local dir = vim.fn.fnamemodify(ctx.file, ':p:h')
|
||||
vim.fn.mkdir(dir, 'p')
|
||||
end
|
||||
})
|
||||
|
||||
auto('WinLeave', {
|
||||
desc = 'Unset cursorline',
|
||||
group = toggles,
|
||||
callback = function() vim.opt.cursorline = false end
|
||||
})
|
||||
|
||||
auto('WinEnter', {
|
||||
desc = 'Set cursorline',
|
||||
group = toggles,
|
||||
callback = function()
|
||||
if vim.bo.filetype ~= 'alpha' then
|
||||
vim.opt.cursorline = true
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
auto('ColorScheme', {
|
||||
desc = 'Update statusline on colorscheme change',
|
||||
group = winchange,
|
||||
callback = function() require('el').reset_windows() end
|
||||
})
|
50
lua/conf/autos.lua
Normal file
50
lua/conf/autos.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local misc = require('core.misc')
|
||||
local auto, augroup = misc.auto, misc.augroup
|
||||
|
||||
-- auto commands which interact with bufferes without modifying them
|
||||
local bufcheck = augroup('bufcheck')
|
||||
-- auto commands which modify things on the filesystem
|
||||
local fsmod = augroup('fsmod')
|
||||
|
||||
auto('FocusGained', {
|
||||
group = bufcheck,
|
||||
desc = 'Update contents of file.',
|
||||
command = 'checktime',
|
||||
})
|
||||
|
||||
auto('TextYankPost', {
|
||||
pattern = '*',
|
||||
group = bufcheck,
|
||||
desc = 'Highlight on yank.',
|
||||
callback = function()
|
||||
vim.highlight.on_yank { timeout = 250 }
|
||||
end
|
||||
})
|
||||
|
||||
auto('BufRead', {
|
||||
pattern = '*',
|
||||
group = bufcheck,
|
||||
desc = 'Return to the last place the buffer was closed in.',
|
||||
callback = function()
|
||||
vim.cmd([[call setpos(".", getpos("'\""))]])
|
||||
vim.api.nvim_input('zz')
|
||||
end
|
||||
})
|
||||
|
||||
auto('BufWritePre', {
|
||||
pattern = '*',
|
||||
group = fsmod,
|
||||
desc = 'remove trailing spaces on file save',
|
||||
command = [[%s/\s\+$//e]]
|
||||
})
|
||||
|
||||
auto('BufWritePre', {
|
||||
pattern = '*',
|
||||
group = fsmod,
|
||||
desc = 'Basically mkdir -p.',
|
||||
callback = function(ctx)
|
||||
if ctx.match:match("^%w%w+://") then return end
|
||||
local dir = vim.fn.fnamemodify(ctx.file, ':p:h')
|
||||
vim.fn.mkdir(dir, 'p')
|
||||
end
|
||||
})
|
@ -1,25 +1,11 @@
|
||||
local conf = require('core.conf')
|
||||
local misc = require('core.misc')
|
||||
local map, auto = misc.map, misc.auto
|
||||
|
||||
local function map(mode, bind, cmd, opts)
|
||||
opts = opts or {}
|
||||
opts['noremap'] = true
|
||||
opts['silent'] = true
|
||||
|
||||
if type(bind) == 'table' then
|
||||
for i in pairs(bind) do
|
||||
vim.keymap.set(mode, bind[i], cmd, opts)
|
||||
end
|
||||
elseif type(bind) == 'string' then
|
||||
vim.keymap.set(mode, bind, cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- vim binds ------------------------------------------------------------------
|
||||
g.mapleader = ' ' -- set leader key
|
||||
-- vim binds
|
||||
vim.g.mapleader = ' ' -- set leader key
|
||||
|
||||
map('x', '<leader>p', [["_dP]], { desc = 'Greatest remap of all time.' })
|
||||
map('n', '<esc>', ':nohlsearch<Bar>:echo<CR>', { desc = 'Clear search.' })
|
||||
map('t', '<esc>', '<C-\\><C-n>', { desc = 'make <esc> work in terminals.' })
|
||||
-- move selected text up/down
|
||||
map('v', '<S-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selected text up.' })
|
||||
map('v', '<S-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selected text down.' })
|
||||
@ -45,22 +31,7 @@ map('n', '<leader>x', function() -- execute order 111
|
||||
else
|
||||
vim.notify("File doesn't exist", vim.log.levels.INFO, { title = misc.appid })
|
||||
end
|
||||
end)
|
||||
|
||||
-- add some keybinds to the file view (netrw)
|
||||
a.nvim_create_autocmd('FileType', {
|
||||
pattern = 'netrw',
|
||||
callback = function()
|
||||
local function bind(lhs, rhs)
|
||||
vim.keymap.set('n', lhs, rhs, { remap = true, buffer = true })
|
||||
end
|
||||
bind('h', '-^') -- Go up a directory
|
||||
bind('l', '<CR>') -- Go down a directory / open a file
|
||||
bind('.', 'gh') -- Toggle hidden files
|
||||
bind('P', '<C-w>z') -- Close preview window
|
||||
bind('<esc>', '<cmd>q<CR>') -- Close netrw
|
||||
end
|
||||
})
|
||||
end, { desc = 'toggle executable flag of the file' })
|
||||
|
||||
-- tabs
|
||||
map('n', '[]', '<cmd>tabnew<CR>')
|
||||
@ -68,118 +39,22 @@ map('n', '][', '<cmd>tabc<CR>')
|
||||
map('n', '[[', '<cmd>tabp<CR>')
|
||||
map('n', ']]', '<cmd>tabn<CR>')
|
||||
|
||||
-- config binds ---------------------------------------------------------------
|
||||
map('n', '<leader>m', conf.configmenu, { desc = 'Neovim config manager menu', })
|
||||
|
||||
-- plugin binds ---------------------------------------------------------------
|
||||
|
||||
-- pretty lsp view
|
||||
map('n', 'gd', '<CMD>Glance definitions<CR>')
|
||||
map('n', 'gr', '<CMD>Glance references<CR>')
|
||||
map('n', 'gy', '<CMD>Glance type_definitions<CR>')
|
||||
map('n', 'gi', '<CMD>Glance implementations<CR>')
|
||||
|
||||
if pcall(require, "treesj") then
|
||||
local treesj = require('treesj') -- treesj
|
||||
map('n', '<leader>j', treesj.toggle)
|
||||
end
|
||||
|
||||
if pcall(require, "telescope") then
|
||||
local telebuilt = require('telescope.builtin') -- telescope
|
||||
-- local telexten = require('telescope').extensions
|
||||
map('n', '<leader>sf', telebuilt.find_files, { desc = 'Find files.' })
|
||||
map('n', '<leader>so', telebuilt.oldfiles, { desc = 'Find old files.' })
|
||||
map('n', '<leader>sg', telebuilt.git_files, { desc = 'Find git files.' })
|
||||
-- search urls in buffer
|
||||
map('n', '<leader>su', '<Cmd>UrlView<CR>', { desc = 'Find urls in buffer.' })
|
||||
-- search lsp symbols
|
||||
map('n', '<leader>ss', telebuilt.lsp_document_symbols,
|
||||
{ desc = 'Find LSP Symbols.' })
|
||||
-- search for keybinds
|
||||
map('n', '<leader>sk', telebuilt.keymaps,
|
||||
{ desc = 'Find nvim Keymaps.' })
|
||||
-- search for highlights
|
||||
map('n', '<leader>sh', telebuilt.highlights,
|
||||
{ desc = 'Find nvim Highlights.' })
|
||||
-- search for autocommands
|
||||
map('n', '<leader>sa', telebuilt.autocommands,
|
||||
{ desc = 'Find nvim Autocommands.' })
|
||||
-- search for vim options
|
||||
map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' })
|
||||
-- search for string in project
|
||||
map('n', '<leader>sp', telebuilt.live_grep, { desc = 'Find string in project.' })
|
||||
|
||||
-- Code Actions (requires telescope)
|
||||
if pcall(require, "actions-preview") then
|
||||
map({ "n", "v" }, "<leader>ca", require("actions-preview").code_actions, {
|
||||
desc = 'preview code actions'
|
||||
})
|
||||
-- good spell suggestion ui
|
||||
-- (stolen from https://github.com/neovim/neovim/pull/25833)
|
||||
local spell_on_choice = vim.schedule_wrap(function(_, idx)
|
||||
if type(idx) == 'number' then
|
||||
vim.cmd('normal! ' .. idx .. 'z=')
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- todo list
|
||||
if pcall(require, "todo-comments") then
|
||||
map("n", "<leader>td", "<cmd>TodoQuickFix<CR>", { desc = 'open up list of TODO\'s' })
|
||||
end
|
||||
|
||||
-- harpoon
|
||||
if (pcall(require, 'harpoon')) then
|
||||
local harpoon = require("harpoon")
|
||||
|
||||
map("n", "<leader>a", function()
|
||||
harpoon:list():append()
|
||||
vim.notify('added new file to quickmarks', vim.log.levels.INFO, {
|
||||
title = misc.appid,
|
||||
})
|
||||
end)
|
||||
map('n', '<C-q>', function() harpoon:list():select(1) end)
|
||||
map('n', '<C-g>', function() harpoon:list():select(2) end)
|
||||
map('n', '<C-h>', function() harpoon:list():select(3) end)
|
||||
map('n', '<C-i>', function() harpoon:list():select(4) end)
|
||||
|
||||
map("n", "<C-S-P>", function() harpoon:list():prev() end)
|
||||
map("n", "<C-S-N>", function() harpoon:list():next() end)
|
||||
|
||||
map("n", "<C-e>", function() require("core.harpoon").switcher() end)
|
||||
end
|
||||
|
||||
map('n', '<leader>u', '<cmd>UndotreeToggle<CR>', { desc = 'Open undo tree.' })
|
||||
map('n', '<leader>f', '<cmd>SFMToggle<CR>', { desc = 'Open file tree view.' })
|
||||
map('n', '<C-j>', '<cmd>JABSOpen<CR>', { desc = 'Switch between buffers.' })
|
||||
|
||||
if pcall(require, "smart-splits") then
|
||||
local smartsplits = require('smart-splits') -- resizing buffers (toggleable)
|
||||
map('n', '<leader>r', smartsplits.start_resize_mode)
|
||||
end
|
||||
|
||||
-- neogen
|
||||
if pcall(require, "neogen") then
|
||||
map('n', '<leader>df', require("neogen").generate, {
|
||||
desc = 'Generate anotations',
|
||||
})
|
||||
end
|
||||
|
||||
-- venn
|
||||
function _G.Toggle_venn()
|
||||
local mapb = vim.api.nvim_buf_set_keymap
|
||||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||
if venn_enabled == "nil" then
|
||||
vim.notify("Enabled venn mode", vim.log.levels.LOW, { title = misc.appid })
|
||||
vim.b.venn_enabled = true
|
||||
vim.cmd([[setlocal ve=all]])
|
||||
-- draw a line on HJKL keystokes
|
||||
mapb(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
|
||||
mapb(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
|
||||
mapb(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
|
||||
mapb(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
|
||||
-- draw a box by pressing "f" with visual selection
|
||||
mapb(0, "v", "f", ":VBox<CR>", { noremap = true })
|
||||
else
|
||||
vim.notify("Disabled venn mode", vim.log.levels.LOW, { title = misc.appid })
|
||||
vim.cmd[[setlocal ve=]]
|
||||
vim.cmd[[mapclear <buffer>]]
|
||||
vim.b.venn_enabled = nil
|
||||
local spellsuggest_select = function()
|
||||
if vim.v.count > 0 then
|
||||
spell_on_choice(nil, vim.v.count)
|
||||
return
|
||||
end
|
||||
local cword = vim.fn.expand('<cword>')
|
||||
local prompt = 'Change ' .. vim.inspect(cword) .. ' to:'
|
||||
vim.ui.select(vim.fn.spellsuggest(cword, vim.o.lines), { prompt = prompt }, spell_on_choice)
|
||||
end
|
||||
-- toggle keymappings for venn using <leader>v
|
||||
map('n', '<leader>v', ":lua Toggle_venn()<CR>")
|
||||
|
||||
vim.keymap.set('n', 'z=', spellsuggest_select, { desc = 'Shows spelling suggestions' })
|
||||
|
20
lua/conf/context.lua
Normal file
20
lua/conf/context.lua
Normal file
@ -0,0 +1,20 @@
|
||||
-- clear menu
|
||||
vim.cmd([[:aunmenu PopUp]])
|
||||
|
||||
-- add menu items
|
||||
vim.cmd([[:amenu PopUp.Save\ Buffer <cmd>:w<CR>]])
|
||||
vim.cmd([[:amenu PopUp.Save\ All\ Buffers <cmd>:wa<CR>]])
|
||||
vim.cmd([[:nmenu PopUp.Select\ All ggVG]])
|
||||
vim.cmd([[:nmenu PopUp.Undo u]])
|
||||
vim.cmd([[:nmenu PopUp.Redo <C-r>]])
|
||||
vim.cmd([[:nmenu PopUp.Inspect <cmd>Inspect<CR>]])
|
||||
vim.cmd([[:amenu PopUp.-1- <nop>]]) -- dividers
|
||||
vim.cmd([[:nmenu PopUp.Copy\ Line yy]])
|
||||
vim.cmd([[:vmenu PopUp.Copy\ Selection y]])
|
||||
vim.cmd([[:amenu PopUp.Paste p]])
|
||||
vim.cmd([[:vmenu PopUp.Cut d]])
|
||||
vim.cmd([[:nmenu PopUp.Cut dd]])
|
||||
vim.cmd([[:vmenu PopUp.-2- <nop>]]) -- dividers
|
||||
vim.cmd([[:nmenu PopUp.-2- <nop>]]) -- dividers
|
||||
vim.cmd([[:vmenu PopUp.Format\ Selection =]])
|
||||
vim.cmd([[:nmenu PopUp.Format\ Line ==]])
|
@ -1,4 +0,0 @@
|
||||
misc.include('conf.plugins') -- load plugins first to allow colorscheme to be set in opts
|
||||
misc.include('conf.opts')
|
||||
misc.include('conf.binds')
|
||||
misc.include('conf.auto')
|
@ -1,65 +1,50 @@
|
||||
-- better ui ------------------------------------------------------------------
|
||||
if pcall(require, "notify") then vim.notify = require("notify") end
|
||||
o.colorcolumn = { 80 }
|
||||
-- color stuff
|
||||
if vim.fn.has("termguicolors") then
|
||||
vim.opt.termguicolors = true
|
||||
end
|
||||
|
||||
-- buffer
|
||||
o.scrolloff = 5
|
||||
o.wrap = true -- wraping lines
|
||||
o.linebreak = true -- fix where line is wraped
|
||||
o.cursorline = true
|
||||
|
||||
-- statusbar
|
||||
o.laststatus = 3
|
||||
o.cmdheight = 1
|
||||
o.showmode = false -- stop vim from showing mode (we have a statusbar)
|
||||
|
||||
-- tabline
|
||||
o.showtabline = 2
|
||||
vim.opt.scrolloff = 5
|
||||
vim.opt.wrap = true -- wraping lines
|
||||
vim.opt.linebreak = true -- fix where line is wraped
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- indents + tabs
|
||||
local tabwidth = 2
|
||||
o.expandtab = true
|
||||
o.smarttab = true
|
||||
o.cindent = true
|
||||
o.autoindent = true
|
||||
o.tabstop = tabwidth
|
||||
o.shiftwidth = tabwidth
|
||||
o.softtabstop = tabwidth
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.smarttab = true
|
||||
vim.opt.cindent = true
|
||||
vim.opt.autoindent = true
|
||||
vim.opt.tabstop = tabwidth
|
||||
vim.opt.shiftwidth = tabwidth
|
||||
vim.opt.softtabstop = tabwidth
|
||||
|
||||
-- colorscheme
|
||||
if vim.fn.has("termguicolors") then
|
||||
o.termguicolors = true
|
||||
end
|
||||
misc.colorscheme('mellow')
|
||||
vim.opt.clipboard = 'unnamedplus' -- system clipboard
|
||||
vim.opt.updatetime = 200
|
||||
|
||||
-- better editing -------------------------------------------------------------
|
||||
o.clipboard = 'unnamedplus' -- system clipboard
|
||||
o.splitkeep = "screen" -- keep same text on screen when spliting
|
||||
o.updatetime = 200
|
||||
-- file saving
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.undofile = true
|
||||
vim.opt.confirm = true
|
||||
|
||||
-- file saving ----------------------------------------------------------------
|
||||
o.swapfile = false
|
||||
o.undofile = true
|
||||
o.confirm = true
|
||||
-- searching
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.wrapscan = true
|
||||
vim.opt.showmatch = true
|
||||
vim.opt.incsearch = true
|
||||
|
||||
-- searching ------------------------------------------------------------------
|
||||
o.ignorecase = true
|
||||
o.smartcase = true
|
||||
o.wrapscan = true
|
||||
o.showmatch = true
|
||||
o.incsearch = true
|
||||
-- wild menus
|
||||
vim.opt.wildoptions = 'pum'
|
||||
vim.opt.pumblend = 3
|
||||
vim.opt.pumheight = 20
|
||||
|
||||
-- wild menus -----------------------------------------------------------------
|
||||
o.wildoptions = 'pum'
|
||||
o.pumblend = 3
|
||||
o.pumheight = 20
|
||||
vim.opt.wildignorecase = true
|
||||
vim.opt.wildignore = '*.o'
|
||||
|
||||
o.wildignorecase = true
|
||||
o.wildignore = '*.o'
|
||||
|
||||
-- netrw ----------------------------------------------------------------------
|
||||
g.netrw_banner = 1
|
||||
g.netrw_localcopydircmd = 'cp -r'
|
||||
g.netrw_winsize = 30
|
||||
g.netrw_liststyle = 1
|
||||
g.netrw_preview = 1
|
||||
-- netrw
|
||||
vim.g.netrw_banner = 0
|
||||
vim.g.netrw_winsize = 30
|
||||
vim.g.netrw_liststyle = 1
|
||||
vim.g.netrw_sizestyle = "H"
|
||||
vim.g.netrw_hide = 1
|
||||
|
@ -1,167 +0,0 @@
|
||||
require('dep') {
|
||||
-- dep manages dep ----------------------------------------------------------
|
||||
{ 'squibid/dep',
|
||||
url = 'https://git.squi.bid/dep',
|
||||
pin = true,
|
||||
-- branch = 'dev'
|
||||
},
|
||||
|
||||
-- colorschemes -------------------------------------------------------------
|
||||
{ 'mellow-theme/mellow.nvim',
|
||||
requires = 'nvim-treesitter/nvim-treesitter'
|
||||
},
|
||||
|
||||
-- ui -----------------------------------------------------------------------
|
||||
{ 'lukas-reineke/indent-blankline.nvim' }, -- indentation indicators
|
||||
{ 'folke/which-key.nvim' }, -- key map help
|
||||
{ 'rcarriga/nvim-notify' }, -- notifications
|
||||
{ 'tjdevries/express_line.nvim', -- status bar
|
||||
requires = 'nvim-lua/plenary.nvim'
|
||||
},
|
||||
{ 'goolord/alpha-nvim' }, -- start page
|
||||
{ 'dinhhuy258/sfm.nvim', -- tree view
|
||||
deps = 'dinhhuy258/sfm-git.nvim'
|
||||
},
|
||||
{ 'matbme/JABS.nvim' }, -- buffer switcher
|
||||
{ 'stevearc/dressing.nvim', -- nice ui selectors
|
||||
requires = 'nvim-telescope/telescope.nvim'
|
||||
},
|
||||
{ 'lukas-reineke/headlines.nvim',
|
||||
requires = 'nvim-neorg/neorg'
|
||||
},
|
||||
{ 'squibid/tar', -- tab bar
|
||||
url = 'https://git.squi.bid/tar'
|
||||
},
|
||||
|
||||
-- functional plugins -------------------------------------------------------
|
||||
{ 'lewis6991/gitsigns.nvim' }, -- very helpful git things
|
||||
{ 'chentoast/marks.nvim' }, -- marks in gutter
|
||||
{ 'vidocqh/auto-indent.nvim' }, -- better tabbing into indents
|
||||
{ 'mbbill/undotree' }, -- careful this one is written in vimscript
|
||||
{ 'dhruvasagar/vim-table-mode' }, -- same with this one
|
||||
{ 'altermo/ultimate-autopair.nvim', -- autopairs
|
||||
branch = 'v0.6'
|
||||
},
|
||||
{ 'numToStr/Comment.nvim' },
|
||||
{ 'ahmedkhalf/project.nvim' }, -- cd into root of project
|
||||
{ 'mrjones2014/smart-splits.nvim'}, -- buffer resizing
|
||||
{ 'ThePrimeagen/harpoon', -- super duper fast navigation through files
|
||||
branch = 'harpoon2',
|
||||
requires = 'nvim-lua/plenary.nvim'
|
||||
},
|
||||
|
||||
-- note taking --------------------------------------------------------------
|
||||
{ 'nvim-neorg/neorg',
|
||||
branch = '*',
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'folke/zen-mode.nvim',
|
||||
{ 'vhyrro/luarocks.nvim',
|
||||
config = function()
|
||||
-- NOTE: you need the lua.h header file for lua version 5.1 and
|
||||
-- luarocks on void linux run: xbps-install luarocks lua51-devel
|
||||
|
||||
local output = ""
|
||||
local function cbstd(_, data, _)
|
||||
data = table.concat(data)
|
||||
data = data:gsub("\r", "\n")
|
||||
output = output..data
|
||||
end
|
||||
-- actually start the build here
|
||||
vim.fn.jobstart({ "nvim", "-l", "build.lua" }, {
|
||||
on_stdout = cbstd,
|
||||
on_stderr = cbstd,
|
||||
on_exit = function()
|
||||
-- return build status as a notification
|
||||
vim.notify(output, vim.log.levels.INFO, { title = misc.appid })
|
||||
end
|
||||
})
|
||||
end
|
||||
}
|
||||
},
|
||||
deps = { 'nvim-neorg/neorg-telescope',
|
||||
requires = 'nvim-telescope/telescope.nvim'
|
||||
}
|
||||
},
|
||||
|
||||
{ 'jbyuki/venn.nvim' },
|
||||
|
||||
-- fzf ----------------------------------------------------------------------
|
||||
{ 'nvim-telescope/telescope.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
deps = {
|
||||
'nvim-telescope/telescope-file-browser.nvim',
|
||||
'nvim-telescope/telescope-symbols.nvim',
|
||||
'axieax/urlview.nvim'
|
||||
}
|
||||
},
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
||||
config = function()
|
||||
vim.cmd('make')
|
||||
end,
|
||||
requires = 'nvim-telescope/telescope.nvim'
|
||||
},
|
||||
|
||||
-- treesitter + colorizing --------------------------------------------------
|
||||
{ 'nvim-treesitter/nvim-treesitter',
|
||||
deps = {
|
||||
'Wansmer/treesj',
|
||||
'nvim-treesitter/nvim-treesitter-context'
|
||||
}
|
||||
},
|
||||
{ 'NvChad/nvim-colorizer.lua' },
|
||||
{ 'folke/todo-comments.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim'
|
||||
},
|
||||
|
||||
-- cmp ----------------------------------------------------------------------
|
||||
{ 'hrsh7th/nvim-cmp',
|
||||
deps = {
|
||||
'lukas-reineke/cmp-under-comparator', -- better results
|
||||
'hrsh7th/cmp-buffer', -- buffers
|
||||
'FelipeLema/cmp-async-path', -- path
|
||||
'hrsh7th/cmp-nvim-lsp', -- lsp
|
||||
'hrsh7th/cmp-nvim-lua', -- nvim lua api
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information
|
||||
{ 'L3MON4D3/cmp-luasnip-choice', -- luasnip
|
||||
requires = 'L3MON4D3/LuaSnip'
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
-- snippets -----------------------------------------------------------------
|
||||
{ 'L3MON4D3/LuaSnip',
|
||||
deps = 'rafamadriz/friendly-snippets',
|
||||
config = function()
|
||||
vim.cmd('make install_jsregexp')
|
||||
end
|
||||
},
|
||||
|
||||
-- lsp ----------------------------------------------------------------------
|
||||
{ 'neovim/nvim-lspconfig' }, -- setup lsp
|
||||
{ 'j-hui/fidget.nvim', -- shows lsp progress
|
||||
branch = 'legacy'
|
||||
},
|
||||
|
||||
{ 'dnlhc/glance.nvim' }, -- diagnostic info at a glance
|
||||
{ 'aznhe21/actions-preview.nvim', -- codeactions
|
||||
requires = 'nvim-telescope/telescope.nvim'
|
||||
},
|
||||
|
||||
{ 'danymat/neogen', -- generate lsp annotations
|
||||
requires = 'nvim-treesitter/nvim-treesitter'
|
||||
},
|
||||
|
||||
{ 'whynothugo/lsp_lines.nvim',
|
||||
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim'
|
||||
},
|
||||
|
||||
-- mason --------------------------------------------------------------------
|
||||
{ 'williamboman/mason.nvim',
|
||||
deps = {
|
||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||
'williamboman/mason-lspconfig.nvim'
|
||||
}
|
||||
}
|
||||
}
|
1
lua/conf/plugins/biscuit.lua
Normal file
1
lua/conf/plugins/biscuit.lua
Normal file
@ -0,0 +1 @@
|
||||
return { 'Biscuit-Theme/nvim' }
|
170
lua/conf/plugins/cmp.lua
Normal file
170
lua/conf/plugins/cmp.lua
Normal file
@ -0,0 +1,170 @@
|
||||
local function has_words_before()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)
|
||||
[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
return { 'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'danymat/neogen',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'lukas-reineke/cmp-under-comparator' -- better results
|
||||
},
|
||||
|
||||
-- suppliers for completions (they require nvim-cmp to be loaded before they are)
|
||||
deps = {
|
||||
'hrsh7th/cmp-buffer', -- buffers
|
||||
'FelipeLema/cmp-async-path', -- path
|
||||
'hrsh7th/cmp-nvim-lsp', -- lsp
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information
|
||||
{ 'L3MON4D3/cmp-luasnip-choice', -- luasnip
|
||||
requires = 'L3MON4D3/LuaSnip'
|
||||
}
|
||||
},
|
||||
|
||||
function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
local neogen = require('neogen')
|
||||
|
||||
cmp.setup {
|
||||
-- disable when in comments
|
||||
enabled = function()
|
||||
local context = require('cmp.config.context')
|
||||
if vim.api.nvim_get_mode().mode == 'c' then
|
||||
return true
|
||||
else
|
||||
return not context.in_treesitter_capture("comment")
|
||||
and not context.in_syntax_group("Comment")
|
||||
end
|
||||
end,
|
||||
|
||||
-- completion sources
|
||||
sources = cmp.config.sources {
|
||||
{ name = 'nvim_lsp', priority = 999 },
|
||||
{ name = 'luasnip_choice', priority = 750 },
|
||||
{ name = 'buffer', max_item_count = 3 },
|
||||
{ name = 'async_path', max_item_count = 5 },
|
||||
{ name = 'neorg' },
|
||||
{ name = 'nvim_lsp_signature_help' }
|
||||
},
|
||||
|
||||
-- how to sort results
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
require('cmp-under-comparator').under,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
}
|
||||
},
|
||||
|
||||
-- appearance of window
|
||||
window = {
|
||||
completion = {
|
||||
scrollbar = false,
|
||||
border = 'solid',
|
||||
winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC",
|
||||
},
|
||||
documentation = {
|
||||
border = 'solid',
|
||||
winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC",
|
||||
}
|
||||
},
|
||||
|
||||
-- position of window
|
||||
view = {
|
||||
entries = {
|
||||
name = 'custom',
|
||||
selection_order = 'near_cursor'
|
||||
}
|
||||
},
|
||||
|
||||
-- formatting of content
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
local menu_icon = {
|
||||
nvim_lsp = 'λ',
|
||||
nvim_lua = 'v',
|
||||
calc = '+',
|
||||
luasnip = '%',
|
||||
buffer = '@',
|
||||
path = '#'
|
||||
}
|
||||
|
||||
item.menu = menu_icon[entry.source.name]
|
||||
return item
|
||||
end
|
||||
},
|
||||
|
||||
experimental = {
|
||||
ghost_text = true
|
||||
},
|
||||
|
||||
-- snippet integration
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
|
||||
-- mappings
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if #cmp.get_entries() == 1 then
|
||||
cmp.confirm({ select = true })
|
||||
elseif cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
if #cmp.get_entries() == 1 then
|
||||
cmp.confirm({ select = true })
|
||||
end
|
||||
elseif neogen.jumpable() then
|
||||
neogen.jump_next()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
elseif neogen.jumpable(-1) then
|
||||
neogen.jump_prev()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
['<CR>'] = cmp.mapping {
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true }),
|
||||
},
|
||||
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
['<ESC>'] = cmp.mapping.close(),
|
||||
["<C-e>"] = cmp.mapping.abort()
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
7
lua/conf/plugins/comment.lua
Normal file
7
lua/conf/plugins/comment.lua
Normal file
@ -0,0 +1,7 @@
|
||||
return { 'numToStr/Comment.nvim',
|
||||
function()
|
||||
require('Comment').setup {
|
||||
ignore = '^$'
|
||||
}
|
||||
end
|
||||
}
|
21
lua/conf/plugins/dressing.lua
Normal file
21
lua/conf/plugins/dressing.lua
Normal file
@ -0,0 +1,21 @@
|
||||
local branch = nil
|
||||
if vim.version().minor == 7 then
|
||||
branch = 'nvim-0.7'
|
||||
elseif vim.version().minor == 5 then
|
||||
branch = 'nvim-0.5'
|
||||
end
|
||||
|
||||
return { 'stevearc/dressing.nvim',
|
||||
disable = vim.version().minor < 5,
|
||||
branch = branch,
|
||||
requires = 'nvim-telescope/telescope.nvim',
|
||||
function()
|
||||
require('dressing').setup {
|
||||
input = {
|
||||
title_pos = "center",
|
||||
border = 'solid',
|
||||
relative = "win"
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
34
lua/conf/plugins/fidget.lua
Normal file
34
lua/conf/plugins/fidget.lua
Normal file
@ -0,0 +1,34 @@
|
||||
return { 'j-hui/fidget.nvim',
|
||||
disable = vim.version().minor < 9,
|
||||
function()
|
||||
local notification_defaults = require("fidget.notification").default_config
|
||||
notification_defaults["icon"] = ""
|
||||
|
||||
require('fidget').setup {
|
||||
progress = {
|
||||
display = {
|
||||
progress_icon = {
|
||||
pattern = "line",
|
||||
period = 1
|
||||
},
|
||||
done_icon = ":)",
|
||||
}
|
||||
},
|
||||
notification = {
|
||||
override_vim_notify = true,
|
||||
configs = {
|
||||
default = notification_defaults,
|
||||
},
|
||||
view = {
|
||||
icon_separator = " ",
|
||||
group_separator = "---",
|
||||
group_separator_hl = "Comment",
|
||||
},
|
||||
window = {
|
||||
zindex = 44,
|
||||
relative = "win"
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
78
lua/conf/plugins/gitsigns.lua
Normal file
78
lua/conf/plugins/gitsigns.lua
Normal file
@ -0,0 +1,78 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'lewis6991/gitsigns.nvim',
|
||||
disable = vim.version().minor < 9,
|
||||
function()
|
||||
local gs = require("gitsigns")
|
||||
|
||||
gs.setup {
|
||||
signs = {
|
||||
add = { text = '│' },
|
||||
change = { text = '│' },
|
||||
delete = { text = '-' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' }
|
||||
},
|
||||
|
||||
signcolumn = true,
|
||||
numhl = false,
|
||||
linehl = false,
|
||||
word_diff = false,
|
||||
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true
|
||||
},
|
||||
|
||||
attach_to_untracked = true,
|
||||
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
|
||||
|
||||
preview_config = { border = 'solid' },
|
||||
|
||||
on_attach = function(bufnr)
|
||||
local opts = { buffer = bufnr }
|
||||
|
||||
-- Navigation
|
||||
map('n', ']c', function()
|
||||
if vim.wo.diff then
|
||||
return ']c'
|
||||
end
|
||||
vim.schedule(function() gs.next_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, { expr = true, buffer = bufnr })
|
||||
|
||||
map('n', '[c', function()
|
||||
if vim.wo.diff then
|
||||
return '[c'
|
||||
end
|
||||
vim.schedule(function() gs.prev_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, { expr = true, buffer = bufnr })
|
||||
|
||||
-- Actions
|
||||
map('n', '<leader>hs', gs.stage_hunk, opts)
|
||||
map('n', '<leader>hr', gs.reset_hunk, opts)
|
||||
map('v', '<leader>hs', function()
|
||||
gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') }
|
||||
end, opts)
|
||||
map('v', '<leader>hr', function()
|
||||
gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') }
|
||||
end, opts)
|
||||
map('n', '<leader>hS', gs.stage_buffer, opts)
|
||||
map('n', '<leader>hu', gs.undo_stage_hunk, opts)
|
||||
map('n', '<leader>hR', gs.reset_buffer, opts)
|
||||
map('n', '<leader>hp', gs.preview_hunk, opts)
|
||||
map('n', '<leader>hb', function() gs.blame_line { full=true } end, opts)
|
||||
map('n', '<leader>tb', gs.toggle_current_line_blame, opts)
|
||||
map('n', '<leader>hd', gs.diffthis, opts)
|
||||
map('n', '<leader>hD', function() gs.diffthis('~') end, opts)
|
||||
map('n', '<leader>td', gs.toggle_deleted, opts)
|
||||
|
||||
-- Text object
|
||||
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', opts)
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
44
lua/conf/plugins/glance.lua
Normal file
44
lua/conf/plugins/glance.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'dnlhc/glance.nvim',
|
||||
disable = vim.version().minor < 7,
|
||||
function()
|
||||
require('glance').setup {
|
||||
border = {
|
||||
enable = true,
|
||||
top_char = '',
|
||||
bottom_char = '─',
|
||||
},
|
||||
folds = {
|
||||
fold_closed = '+',
|
||||
fold_open = '-',
|
||||
folded = true
|
||||
},
|
||||
theme = {
|
||||
enable = false
|
||||
},
|
||||
hooks = {
|
||||
before_open = function(results, open, jump, method)
|
||||
local uri = vim.uri_from_bufnr(0)
|
||||
if #results == 1 then
|
||||
local target_uri = results[1].uri or results[1].targetUri
|
||||
|
||||
if target_uri == uri then
|
||||
jump()
|
||||
misc.timeout_highlight()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
open()
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
map('n', 'gd', '<cmd>Glance definitions<CR>')
|
||||
map('n', 'gr', '<cmd>Glance references<CR>')
|
||||
map('n', 'gy', '<cmd>Glance type_definitions<CR>')
|
||||
map('n', 'gi', '<cmd>Glance implementations<CR>')
|
||||
end
|
||||
}
|
31
lua/conf/plugins/harpoon.lua
Normal file
31
lua/conf/plugins/harpoon.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'ThePrimeagen/harpoon',
|
||||
disable = vim.version().minor < 8,
|
||||
branch = 'harpoon2',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
function()
|
||||
local harpoon = require("harpoon")
|
||||
|
||||
harpoon:setup()
|
||||
|
||||
map("n", "<leader>a", function()
|
||||
harpoon:list():add()
|
||||
vim.notify("added "..vim.fn.expand("%:t").." to quickmarks", vim.log.levels.INFO, {
|
||||
title = misc.appid,
|
||||
})
|
||||
end, { desc = "add current file to quickmarks" })
|
||||
|
||||
map("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
||||
|
||||
map("n", "<C-h>", function() harpoon:list():select(1) end)
|
||||
map("n", "<C-t>", function() harpoon:list():select(2) end)
|
||||
map("n", "<C-n>", function() harpoon:list():select(3) end)
|
||||
map("n", "<C-s>", function() harpoon:list():select(4) end)
|
||||
|
||||
-- Toggle previous & next buffers stored within Harpoon list
|
||||
map("n", "<C-S-P>", function() harpoon:list():prev() end)
|
||||
map("n", "<C-S-N>", function() harpoon:list():next() end)
|
||||
end
|
||||
}
|
28
lua/conf/plugins/headlines.lua
Normal file
28
lua/conf/plugins/headlines.lua
Normal file
@ -0,0 +1,28 @@
|
||||
return { 'lukas-reineke/headlines.nvim',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
function()
|
||||
require('headlines').setup {
|
||||
norg = {
|
||||
headline_highlights = {
|
||||
"@neorg.headings.1.title",
|
||||
"@neorg.headings.2.title",
|
||||
"@neorg.headings.3.title",
|
||||
"@neorg.headings.4.title",
|
||||
"@neorg.headings.5.title",
|
||||
"@neorg.headings.6.title"
|
||||
},
|
||||
bullets = { "", "", "", "" },
|
||||
},
|
||||
markdown = {
|
||||
headline_highlights = {
|
||||
"@neorg.headings.1.title",
|
||||
"@neorg.headings.2.title",
|
||||
"@neorg.headings.3.title",
|
||||
"@neorg.headings.4.title",
|
||||
"@neorg.headings.5.title",
|
||||
"@neorg.headings.6.title"
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
12
lua/conf/plugins/incline.lua
Normal file
12
lua/conf/plugins/incline.lua
Normal file
@ -0,0 +1,12 @@
|
||||
return { 'b0o/incline.nvim',
|
||||
function()
|
||||
vim.cmd('set laststatus=3')
|
||||
|
||||
require('incline').setup {
|
||||
hide = {
|
||||
focused_win = true,
|
||||
cursorline = true
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
3
lua/conf/plugins/jdtls.lua
Normal file
3
lua/conf/plugins/jdtls.lua
Normal file
@ -0,0 +1,3 @@
|
||||
return { 'mfussenegger/nvim-jdtls',
|
||||
disable = vim.version().minor < 6
|
||||
}
|
14
lua/conf/plugins/lsp_lines.lua
Normal file
14
lua/conf/plugins/lsp_lines.lua
Normal file
@ -0,0 +1,14 @@
|
||||
return { 'whynothugo/lsp_lines.nvim',
|
||||
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim',
|
||||
requires = 'neovim/nvim-lspconfig',
|
||||
function()
|
||||
require('lsp_lines').setup()
|
||||
|
||||
vim.diagnostic.config {
|
||||
virtual_lines = {
|
||||
highlight_whole_line = false,
|
||||
only_current_line = true
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
18
lua/conf/plugins/lspconfig.lua
Normal file
18
lua/conf/plugins/lspconfig.lua
Normal file
@ -0,0 +1,18 @@
|
||||
return { 'neovim/nvim-lspconfig',
|
||||
disable = vim.version().minor < 8,
|
||||
function()
|
||||
vim.diagnostic.config {
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = true
|
||||
}
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, { border = 'solid' })
|
||||
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, { border = 'solid' })
|
||||
end
|
||||
}
|
52
lua/conf/plugins/luasnip.lua
Normal file
52
lua/conf/plugins/luasnip.lua
Normal file
@ -0,0 +1,52 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'L3MON4D3/LuaSnip',
|
||||
branch = 'v2.3.0',
|
||||
disable = vim.version().minor < 7,
|
||||
config = function()
|
||||
vim.cmd('make install_jsregexp')
|
||||
end,
|
||||
function()
|
||||
local luasnip = require('luasnip')
|
||||
local types = require("luasnip.util.types")
|
||||
|
||||
luasnip.config.set_config {
|
||||
history = true, -- return back into snippet
|
||||
updateevents = { "TextChanged", "TextChangedI" }, -- update on text insert
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = {{ "●", "@boolean" }}
|
||||
}
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {
|
||||
virt_text = {{ "●", "@constant" }}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
map({"i", "s"}, { "<C-e>", "<C-a>" }, function()
|
||||
if luasnip.choice_active() then
|
||||
luasnip.change_choice(1)
|
||||
end
|
||||
end)
|
||||
|
||||
map({"i", "s"}, "<C-k>", function()
|
||||
if luasnip.expandable(-1) then
|
||||
luasnip.expand(-1)
|
||||
end
|
||||
end)
|
||||
|
||||
-- load all snippets from snippet directory
|
||||
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", true)) do
|
||||
local fn = file:gsub('^.*/', ''):gsub('%.lua$', '')
|
||||
local ret = misc.include('snippets.'..fn)
|
||||
if type(ret) ~= "boolean" then
|
||||
luasnip.add_snippets(fn, ret, { key = fn })
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
369
lua/conf/plugins/mason-lspconfig.lua
Normal file
369
lua/conf/plugins/mason-lspconfig.lua
Normal file
@ -0,0 +1,369 @@
|
||||
local misc = require('core.misc')
|
||||
local map, auto, augroup = misc.map, misc.auto, misc.augroup
|
||||
|
||||
return { 'williamboman/mason-lspconfig.nvim',
|
||||
requires = {
|
||||
'williamboman/mason.nvim',
|
||||
'mfussenegger/nvim-jdtls',
|
||||
'neovim/nvim-lspconfig'
|
||||
},
|
||||
function()
|
||||
local util = require('lspconfig.util')
|
||||
|
||||
-- configure lsp when attached
|
||||
local function lsp_attach(client, bufnr)
|
||||
-- helper function(s)
|
||||
local function set_lsp_sign(name, text)
|
||||
vim.fn.sign_define(name, { text = text, texthl = name })
|
||||
end
|
||||
|
||||
set_lsp_sign("DiagnosticSignError", "x")
|
||||
set_lsp_sign("DiagnosticSignWarn" , "!")
|
||||
set_lsp_sign("DiagnosticSignInfo" , "i")
|
||||
set_lsp_sign("DiagnosticSignHint" , "h")
|
||||
|
||||
local opts = { buffer = bufnr }
|
||||
-- LSP actions
|
||||
map('n', 'K', vim.lsp.buf.hover, opts)
|
||||
map('n', 'gD', vim.lsp.buf.definition, opts)
|
||||
-- map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||
map('n', 'gI', vim.lsp.buf.implementation, opts)
|
||||
map('n', 'gY', vim.lsp.buf.type_definition, opts)
|
||||
map('n', 'gR', vim.lsp.buf.references, opts)
|
||||
map('n', '<S-Tab>', vim.lsp.buf.signature_help, opts)
|
||||
map('n', '<leader>lr', vim.lsp.buf.rename, opts)
|
||||
map('n', '<F2>', vim.lsp.buf.rename, opts)
|
||||
map('n', 'gA', vim.lsp.buf.code_action, {
|
||||
buffer = bufnr,
|
||||
desc = 'check code actions',
|
||||
})
|
||||
map('n', '<F4>', vim.lsp.buf.code_action, {
|
||||
buffer = bufnr,
|
||||
desc = 'check code actions'
|
||||
})
|
||||
|
||||
-- Diagnostics
|
||||
map('n', '[d', vim.diagnostic.goto_prev)
|
||||
map('n', ']d', vim.diagnostic.goto_next)
|
||||
end
|
||||
|
||||
-- setup lsp capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem = {
|
||||
documentationFormat = { "markdown", "plaintext" },
|
||||
snippetSupport = true,
|
||||
preselectSupport = true,
|
||||
insertReplaceSupport = true,
|
||||
labelDetailsSupport = true,
|
||||
deprecatedSupport = true,
|
||||
commitCharactersSupport = true,
|
||||
tagSupport = {
|
||||
valueSet = { 1 }
|
||||
},
|
||||
resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- setup language servers
|
||||
require('mason-lspconfig').setup {
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"clangd",
|
||||
"jdtls",
|
||||
"tsserver",
|
||||
"phpactor",
|
||||
"html",
|
||||
"cssls",
|
||||
"bashls",
|
||||
"zls"
|
||||
-- "asm-lsp", -- seems to be broken
|
||||
}
|
||||
}
|
||||
require('mason-lspconfig').setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = lsp_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
end,
|
||||
|
||||
-- setup luals
|
||||
["lua_ls"] = function(server_name)
|
||||
local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc',
|
||||
'.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml',
|
||||
'README.md'
|
||||
}
|
||||
|
||||
-- FIXME: for some reason luals randomly resets the indentation of code
|
||||
-- when pressing o or O. Right now this is a minor annoyance I will deal
|
||||
-- with in exchange for really good lua lsp support.
|
||||
--
|
||||
-- FIXME: luals also seems to start up twice and sends back twice the
|
||||
-- completions (one configured with the below settings and one without)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = lsp_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim", 'mp' }
|
||||
},
|
||||
runtime = {
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
format = {
|
||||
enable = false
|
||||
},
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
root_dir = function(fname)
|
||||
local root = util.root_pattern(unpack(root_files))(fname)
|
||||
if root and root ~= vim.env.HOME then
|
||||
return root
|
||||
end
|
||||
|
||||
root = util.root_pattern('lua/')(fname)
|
||||
if root then
|
||||
return root
|
||||
end
|
||||
return util.find_git_ancestor(fname)
|
||||
end
|
||||
}
|
||||
end,
|
||||
|
||||
-- setup clangd
|
||||
["clangd"] = function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = function(client, bufnr)
|
||||
lsp_attach(client, bufnr)
|
||||
|
||||
-- add some clangd specific mappings
|
||||
local opts = { buffer = bufnr }
|
||||
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
||||
end,
|
||||
capabilities = capabilities,
|
||||
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--header-insertion=iwyu",
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
"--fallback-style=llvm"
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
clangdFileStatus = true,
|
||||
fallback_flags = {
|
||||
"-xc" -- makes clangd think we're using c instead of c++
|
||||
}
|
||||
}
|
||||
}
|
||||
end,
|
||||
|
||||
-- setup jdtls
|
||||
["jdtls"] = function(server_name)
|
||||
auto("Filetype", {
|
||||
pattern = "java",
|
||||
callback = function()
|
||||
-- must be a java interpreter of version 17 or greater
|
||||
local java = "java"
|
||||
|
||||
local buffer = {}
|
||||
---@type function
|
||||
local startlsp
|
||||
|
||||
-- check if version of java in use is high enough
|
||||
vim.fn.jobstart({ java, vim.fn.stdpath('config').."/extras/JavaVersion.java" }, {
|
||||
stdin = nil,
|
||||
on_stdout = function(_, data, _)
|
||||
table.insert(buffer, table.concat(data))
|
||||
end,
|
||||
on_exit = function(_, exit_code, _)
|
||||
local v = vim.version.parse(table.concat(buffer))
|
||||
|
||||
-- if there's an error, no version info, or the java version is
|
||||
-- less than 17 stop the lsp from starting
|
||||
if exit_code ~= 0 then
|
||||
vim.notify(string.format(
|
||||
"java version check failed: exit code %s", exit_code),
|
||||
vim.log.levels.ERROR, { title = misc.appid })
|
||||
return
|
||||
elseif not v then
|
||||
vim.notify("no java version info found", vim.log.levels.ERROR,
|
||||
{ title = misc.appid })
|
||||
return
|
||||
elseif v.major < 17 then
|
||||
vim.notify(string.format(
|
||||
"java version %s < 17.0.0 Cannot run jdtls, bailing out",
|
||||
v[1].."."..v[2].."."..v[3]),
|
||||
vim.log.levels.ERROR, { title = misc.appid })
|
||||
return
|
||||
end
|
||||
|
||||
startlsp()
|
||||
end
|
||||
})
|
||||
|
||||
function startlsp()
|
||||
local ok, jdtls = pcall(require, "jdtls")
|
||||
if not ok then
|
||||
vim.notify("jdtls not found, can't start java lsp",
|
||||
vim.log.levels.ERROR, {})
|
||||
return
|
||||
end
|
||||
|
||||
local config = {}
|
||||
|
||||
config.on_attach = function(client, bufnr)
|
||||
lsp_attach(client, bufnr)
|
||||
|
||||
-- add some jdtls specific mappings
|
||||
local opts = { buffer = bufnr }
|
||||
map('n', 'cri', jdtls.organize_imports, opts)
|
||||
map('n', 'crv', jdtls.extract_variable, opts)
|
||||
map('n', 'crc', jdtls.extract_constant, opts)
|
||||
map('x', 'crv', "<esc><cmd>lua require('jdtls').extract_variable(true)<cr>", opts)
|
||||
map('x', 'crc', "<esc><cmd>lua require('jdtls').extract_constant(true)<cr>", opts)
|
||||
map('x', 'crm', "<esc><Cmd>lua require('jdtls').extract_method(true)<cr>", opts)
|
||||
|
||||
-- refresh the codelens every time after writing the file
|
||||
local jdtls_cmds = augroup("jdtls_cmds")
|
||||
|
||||
pcall(vim.lsp.codelens.refresh)
|
||||
auto('BufWritePost', {
|
||||
buffer = bufnr,
|
||||
group = jdtls_cmds,
|
||||
desc = 'refresh codelens',
|
||||
callback = function()
|
||||
pcall(vim.lsp.codelens.refresh)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- setup path stuff
|
||||
local path = {}
|
||||
local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path()
|
||||
path.data_dir = vim.fn.stdpath('cache')..'/nvim-jdtls'
|
||||
path.java_agent = jdtls_install..'/lombok.jar'
|
||||
path.launcher_jar = vim.fn.glob(jdtls_install..'/plugins/org.eclipse.equinox.launcher_*.jar')
|
||||
path.platform_config = jdtls_install..'/config_linux'
|
||||
path.bundles = {}
|
||||
|
||||
-- data dir
|
||||
local data_dir = path.data_dir..'/'..vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||
|
||||
-- enable basic capabilities
|
||||
config.capabilities = capabilities
|
||||
|
||||
-- enable some extended client capabilities
|
||||
local extendedClientCapabilities = jdtls.extendedClientCapabilities
|
||||
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
|
||||
|
||||
-- command to start the lsp server
|
||||
config.cmd = {
|
||||
java, -- this has to be java17 or newer
|
||||
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||
'-Dosgi.bundles.defaultStartLevel=4',
|
||||
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||
'-Dlog.protocol=true',
|
||||
'-Dlog.level=ALL',
|
||||
'-Xmx1G',
|
||||
'--add-modules=ALL-SYSTEM',
|
||||
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
|
||||
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
|
||||
'-jar', path.launcher_jar,
|
||||
'-configuration', path.platform_config,
|
||||
'-data', data_dir
|
||||
}
|
||||
|
||||
-- settings
|
||||
config.settings = {
|
||||
java = {
|
||||
eclipse = { downloadSources = true },
|
||||
gradle = { enabled = true },
|
||||
maven = { downloadSources = true },
|
||||
implementationsCodeLens = { enabled = true },
|
||||
referencesCodeLens = { enabled = true },
|
||||
references = { includeDecompiledSources = true },
|
||||
symbols = { includeSourceMethodDeclarations = true },
|
||||
inlayHints = {
|
||||
parameterNames = {
|
||||
enabled = "all"
|
||||
}
|
||||
},
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
"org.hamcrest.MatcherAssert.assertThat",
|
||||
"org.hamcrest.Matchers.*",
|
||||
"org.hamcrest.CoreMatchers.*",
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
"org.mockito.Mockito.*"
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*",
|
||||
"sun.*"
|
||||
},
|
||||
importOrder = {
|
||||
"java",
|
||||
"javax",
|
||||
"com",
|
||||
"org"
|
||||
}
|
||||
},
|
||||
sources = {
|
||||
organizeImports = {
|
||||
starThreshold = 9999,
|
||||
staticStarThreshold = 9999
|
||||
}
|
||||
},
|
||||
codeGeneration = {
|
||||
toString = {
|
||||
template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}'
|
||||
},
|
||||
hashCodeEquals = { useJava7Objects = true },
|
||||
useBlocks = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
config.signatureHelp = { enabled = true }
|
||||
config.flags = { allow_incremental_sync = true }
|
||||
|
||||
-- disable all messages from printing
|
||||
config.handlers = {
|
||||
['language/status'] = function() end
|
||||
}
|
||||
|
||||
config.init_options = {
|
||||
extendedClientCapabilities = extendedClientCapabilities,
|
||||
}
|
||||
|
||||
config.root_dir = vim.fs.root(0, { ".git", "mvnw", ".gradle",
|
||||
"gradlew" })
|
||||
|
||||
-- start it up
|
||||
jdtls.start_or_attach(config)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
31
lua/conf/plugins/mason.lua
Normal file
31
lua/conf/plugins/mason.lua
Normal file
@ -0,0 +1,31 @@
|
||||
return { 'williamboman/mason.nvim',
|
||||
disable = vim.version().minor < 7,
|
||||
function()
|
||||
local mason = require('mason')
|
||||
|
||||
mason.setup {
|
||||
ui = {
|
||||
border = "solid",
|
||||
width = 0.8,
|
||||
height = 0.9,
|
||||
|
||||
icons = {
|
||||
package_installed = "+",
|
||||
package_pending = "?",
|
||||
package_uninstalled = "x"
|
||||
}
|
||||
},
|
||||
keymaps = {
|
||||
toggle_package_expand = "<CR>",
|
||||
install_package = "i",
|
||||
update_package = "u",
|
||||
check_package_version = "c",
|
||||
update_all_packages = "U",
|
||||
check_outdated_packages = "C",
|
||||
uninstall_package = "r",
|
||||
cancel_installation = "<C-c>",
|
||||
apply_language_filter = "<C-f>"
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
35
lua/conf/plugins/mellow.lua
Normal file
35
lua/conf/plugins/mellow.lua
Normal file
@ -0,0 +1,35 @@
|
||||
return { 'mellow-theme/mellow.nvim',
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
function()
|
||||
vim.g.mellow_variant = "dark"
|
||||
local c = require("mellow.colors")[vim.g.mellow_variant]
|
||||
|
||||
vim.g.mellow_highlight_overrides = {
|
||||
-- stop inactive windows from having a darker bg
|
||||
["NormalNC"] = { link = "Normal" },
|
||||
|
||||
-- make floats darker
|
||||
["NormalFloat"] = { fg = c.fg, bg = c.bg_dark },
|
||||
["FloatBorder"] = { link = "NormalFloat" },
|
||||
|
||||
-- neorg headings, looks extra good with lukas-reineke/headlines.nvim
|
||||
["@neorg.headings.1.title"] = { fg = c.yellow, bg = "#2a211c" },
|
||||
["@neorg.headings.1.icon"] = { link = "@neorg.headings.1.title" },
|
||||
|
||||
["@neorg.headings.2.title"] = { fg = c.blue, bg = '#201e25' },
|
||||
["@neorg.headings.2.icon"] = { link = "@neorg.headings.2.title" },
|
||||
|
||||
["@neorg.headings.3.title"] = { fg = c.cyan, bg = '#2b1b20' },
|
||||
["@neorg.headings.3.icon"] = { link = "@neorg.headings.3.title" },
|
||||
|
||||
["@neorg.headings.4.title"] = { fg = c.green, bg = '#1d201e' },
|
||||
["@neorg.headings.4.icon"] = { link = "@neorg.headings.4.title" },
|
||||
|
||||
["@neorg.headings.5.title"] = { fg = c.magenta, bg = '#251a21' },
|
||||
["@neorg.headings.5.icon"] = { link = "@neorg.headings.5.title" },
|
||||
|
||||
["@neorg.headings.6.title"] = { fg = c.white, bg = '#212126' },
|
||||
["@neorg.headings.6.icon"] = { link = "@neorg.headings.6.title" }
|
||||
}
|
||||
end
|
||||
}
|
19
lua/conf/plugins/neogen.lua
Normal file
19
lua/conf/plugins/neogen.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'danymat/neogen',
|
||||
requires = {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'L3MON4D3/LuaSnip'
|
||||
},
|
||||
function()
|
||||
local neogen = require('neogen')
|
||||
neogen.setup {
|
||||
enabled = true,
|
||||
input_after_comment = true,
|
||||
snippet_engine = "luasnip",
|
||||
}
|
||||
|
||||
map('n', '<leader>d', neogen.generate)
|
||||
end
|
||||
}
|
135
lua/conf/plugins/neorg.lua
Normal file
135
lua/conf/plugins/neorg.lua
Normal file
@ -0,0 +1,135 @@
|
||||
-- WARNING: neorg does some pretty stupid stuff when it comes to the plugins it
|
||||
-- wants (using luarocks), in order to get around all that bullshit I've
|
||||
-- manually added it's dependencies. Because I don't want this to randomly break
|
||||
-- I've also pinned neorg to the latest working version that I've messed around
|
||||
-- with.
|
||||
--
|
||||
-- NOTE: for my future self to update this thingy while not breaking
|
||||
-- dependencies take a look at the build.lua for versioning info. Also make sure
|
||||
-- to check the release notes on github for info on breaking changes.
|
||||
|
||||
local workspace_cache = vim.fs.joinpath(vim.fn.stdpath("data"), "neorg-workspace-cache.lua")
|
||||
|
||||
--- populate neorg workspaces from path or cache
|
||||
---@param path string path to populate workspaces from
|
||||
---@param cache boolean? if true will re populate the cache from the fs
|
||||
---@return table workspaces
|
||||
local function populate_workspaces(path, cache)
|
||||
local workspaces = {}
|
||||
cache = cache or false
|
||||
|
||||
if vim.fn.filereadable(workspace_cache) == 1 and not cache then
|
||||
local ok, ret = pcall(dofile, workspace_cache)
|
||||
if ok and type(ret) == "table" then
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
-- loop through all files in path if path is not empty
|
||||
if vim.fn.empty(vim.fn.glob(path)) == 0 then
|
||||
for n, t in vim.fs.dir(path) do
|
||||
if string.sub(n, 1, 1) == "." or (t ~= "directory" and t ~= "link") then
|
||||
goto continue
|
||||
end
|
||||
-- make sure this still works if the last charachter in the path isn't a '/'
|
||||
workspaces[n] = (string.sub(path, #path, #path) == "/") and path..n or path.."/"..n
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
-- write data to cachefile
|
||||
local f = io.open(workspace_cache, "w+")
|
||||
if not f then
|
||||
return workspaces
|
||||
end
|
||||
|
||||
f:write("return")
|
||||
local ret = vim.inspect(workspaces)
|
||||
if type(ret) == "string" then
|
||||
f:write(ret)
|
||||
else
|
||||
f:write("false")
|
||||
end
|
||||
|
||||
f:close()
|
||||
|
||||
return workspaces
|
||||
end
|
||||
|
||||
return { 'nvim-neorg/neorg',
|
||||
disable = vim.version.lt(vim.version(), { 0, 10, 0 }),
|
||||
branch = 'v9.1.1',
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'folke/zen-mode.nvim',
|
||||
'hrsh7th/nvim-cmp',
|
||||
{ 'nvim-neorg/neorg-telescope',
|
||||
requires = 'nvim-telescope/telescope.nvim'
|
||||
},
|
||||
|
||||
-- NOTE: these are usually installed by neorg via luarocks, the versions
|
||||
-- were picked based on the build.lua found in the root of the neorg repo
|
||||
{ 'nvim-neotest/nvim-nio',
|
||||
branch = 'v1.7.0'
|
||||
},
|
||||
{ 'nvim-neorg/lua-utils.nvim',
|
||||
branch = 'v1.0.2'
|
||||
},
|
||||
{ 'MunifTanjim/nui.nvim',
|
||||
branch = '0.3.0'
|
||||
},
|
||||
{ 'pysan3/pathlib.nvim',
|
||||
branch = 'v2.2.2'
|
||||
}
|
||||
},
|
||||
|
||||
function()
|
||||
local wsphome = (os.getenv("XDG_DOCUMENTS_DIR") or
|
||||
(os.getenv("HOME").."/Documents")).."/notes/"
|
||||
|
||||
require('neorg').setup {
|
||||
load = {
|
||||
-- not sure how to sort the modules so ima just put the empty ones first
|
||||
["core.defaults"] = {},
|
||||
["core.export"] = {},
|
||||
["core.export.markdown"] = {},
|
||||
["core.integrations.telescope"] = {},
|
||||
["core.summary"] = {},
|
||||
["core.ui.calendar"] = {},
|
||||
|
||||
["core.completion"] = {
|
||||
config = {
|
||||
engine = "nvim-cmp"
|
||||
}
|
||||
},
|
||||
["core.concealer"] = {
|
||||
config = {
|
||||
folds = false
|
||||
}
|
||||
},
|
||||
["core.dirman"] = {
|
||||
config = {
|
||||
-- a list of available workspaces are generated at runtime >:)
|
||||
workspaces = populate_workspaces(wsphome)
|
||||
}
|
||||
},
|
||||
["core.esupports.metagen"] = {
|
||||
config = {
|
||||
type = "auto"
|
||||
}
|
||||
},
|
||||
["core.presenter"] = {
|
||||
config = {
|
||||
zen_mode = "zen-mode"
|
||||
}
|
||||
},
|
||||
["core.qol.toc"] = {
|
||||
config = {
|
||||
close_after_use = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
11
lua/conf/plugins/nvim-colorizer.lua
Normal file
11
lua/conf/plugins/nvim-colorizer.lua
Normal file
@ -0,0 +1,11 @@
|
||||
return { 'NvChad/nvim-colorizer.lua',
|
||||
disable = vim.version().minor < 7 and not vim.fn.has("termguicolors"),
|
||||
function()
|
||||
require('colorizer').setup {
|
||||
user_default_options = {
|
||||
names = false,
|
||||
css = true
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
18
lua/conf/plugins/project.lua
Normal file
18
lua/conf/plugins/project.lua
Normal file
@ -0,0 +1,18 @@
|
||||
return { 'ahmedkhalf/project.nvim',
|
||||
disable = vim.version().minor < 5,
|
||||
function()
|
||||
require('project_nvim').setup {
|
||||
patterns = {
|
||||
".git",
|
||||
"Makefile",
|
||||
"_darcs",
|
||||
".hg",
|
||||
".bzr",
|
||||
".svn",
|
||||
"package.json",
|
||||
"index.norg",
|
||||
"README.md"
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
78
lua/conf/plugins/telescope.lua
Normal file
78
lua/conf/plugins/telescope.lua
Normal file
@ -0,0 +1,78 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'nvim-telescope/telescope.nvim',
|
||||
disable = vim.version().minor < 9,
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
||||
config = function()
|
||||
vim.cmd('make')
|
||||
end
|
||||
}
|
||||
},
|
||||
function()
|
||||
local telescope = require("telescope")
|
||||
local actions = require('telescope.actions')
|
||||
local action_layout = require("telescope.actions.layout")
|
||||
|
||||
local function telescopew()
|
||||
if vim.o.columns <= 80 then
|
||||
return vim.o.columns
|
||||
else
|
||||
return 0.8
|
||||
end
|
||||
end
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
borderchars = {
|
||||
prompt = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
||||
results = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
||||
preview = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
||||
},
|
||||
winblend = 0,
|
||||
layout_strategy = 'horizontal',
|
||||
sorting_strategy = 'descending',
|
||||
scroll_strategy = 'limit',
|
||||
layout_config = {
|
||||
horizontal = {
|
||||
width = telescopew(),
|
||||
height = 20,
|
||||
prompt_position = 'bottom',
|
||||
anchor = 'N',
|
||||
}
|
||||
},
|
||||
mappings = {
|
||||
i = {
|
||||
["<esc>"] = actions.close,
|
||||
['<C-j>'] = actions.move_selection_next,
|
||||
['<C-k>'] = actions.move_selection_previous,
|
||||
['<C-l>'] = actions.select_default,
|
||||
['<C-u>'] = actions.preview_scrolling_up,
|
||||
['<C-d>'] = actions.preview_scrolling_down,
|
||||
["<C-p>"] = action_layout.toggle_preview
|
||||
},
|
||||
n = {
|
||||
["gg"] = actions.move_to_top,
|
||||
["G"] = actions.move_to_bottom,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local telebuilt = require('telescope.builtin')
|
||||
map('n', '<leader>f', function()
|
||||
telebuilt.fd { follow = true }
|
||||
end, { desc = 'Find files.' })
|
||||
map('n', '<leader>s', telebuilt.live_grep, { desc = 'Find string in project.' })
|
||||
map('n', '<leader>b', telebuilt.current_buffer_fuzzy_find, {
|
||||
desc = 'Find string in current buffer.',
|
||||
})
|
||||
|
||||
-- enable previewing in the default colorscheme switcher
|
||||
telebuilt.colorscheme = function()
|
||||
require("telescope.builtin.__internal").colorscheme { enable_preview = true }
|
||||
end
|
||||
end
|
||||
}
|
42
lua/conf/plugins/todo-comments.lua
Normal file
42
lua/conf/plugins/todo-comments.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local branch = nil
|
||||
if vim.version().minor < 8 then
|
||||
branch = 'neovim-pre-0.8.0'
|
||||
end
|
||||
|
||||
return { 'folke/todo-comments.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
branch = branch,
|
||||
function()
|
||||
require('todo-comments').setup {
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = "# ",
|
||||
alt = { "FIXME", "BUG" },
|
||||
},
|
||||
HACK = {
|
||||
icon = "* ",
|
||||
color = "warning",
|
||||
},
|
||||
WARN = {
|
||||
icon = "! ",
|
||||
color = "warning",
|
||||
alt = { "WARNING", "XXX" },
|
||||
},
|
||||
NOTE = {
|
||||
icon = "i ",
|
||||
color = "hint",
|
||||
alt = { "INFO", "TODO" },
|
||||
},
|
||||
PERF = {
|
||||
icon = "@ ",
|
||||
alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" },
|
||||
},
|
||||
TEST = {
|
||||
icon = "@ ",
|
||||
color = "test",
|
||||
alt = { "TESTING", "PASSED", "FAILED" },
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
40
lua/conf/plugins/treesitter-context.lua
Normal file
40
lua/conf/plugins/treesitter-context.lua
Normal file
@ -0,0 +1,40 @@
|
||||
local misc = require("core.misc")
|
||||
local map = misc.map
|
||||
|
||||
local branch = nil
|
||||
if vim.version().minor == 7 then
|
||||
branch = 'compat/0.7'
|
||||
end
|
||||
|
||||
return { 'nvim-treesitter/nvim-treesitter-context',
|
||||
disable = vim.version().minor < 7,
|
||||
branch = branch,
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
function()
|
||||
local treesitter_context = require("treesitter-context")
|
||||
|
||||
treesitter_context.setup {
|
||||
enable = true,
|
||||
line_numbers = true,
|
||||
separator = '─',
|
||||
}
|
||||
|
||||
-- mapping to jump to the first closest line of context in buffer
|
||||
map("n", "[j", function()
|
||||
local lline = vim.api.nvim_win_get_cursor(0)[1];
|
||||
local line
|
||||
|
||||
-- go to the first closest line of context and center it
|
||||
treesitter_context.go_to_context()
|
||||
vim.api.nvim_input('zz')
|
||||
|
||||
-- make sure we actually moved
|
||||
line = vim.api.nvim_win_get_cursor(0)[1];
|
||||
if line == lline then
|
||||
return
|
||||
end
|
||||
|
||||
misc.timeout_highlight()
|
||||
end)
|
||||
end
|
||||
}
|
59
lua/conf/plugins/treesitter.lua
Normal file
59
lua/conf/plugins/treesitter.lua
Normal file
@ -0,0 +1,59 @@
|
||||
table.contains = function(self, string)
|
||||
for _, v in pairs(self) do
|
||||
if v == string then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return { 'nvim-treesitter/nvim-treesitter',
|
||||
disable = vim.version.lt(vim.version(), { 0, 9, 2 }),
|
||||
config = function()
|
||||
vim.cmd("TSUpdate")
|
||||
end,
|
||||
function()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- good default parsers
|
||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown",
|
||||
"markdown_inline", "java", "bash", "css", "html", "luadoc"
|
||||
},
|
||||
|
||||
-- install missing parsers
|
||||
auto_install = true,
|
||||
|
||||
-- indentation
|
||||
indent = {
|
||||
enable = true,
|
||||
|
||||
disable = function(lang, buf)
|
||||
-- disable indenting in php (it's more broken with than without)
|
||||
return table.contains({
|
||||
"php"
|
||||
}, lang)
|
||||
end
|
||||
},
|
||||
|
||||
-- enable highlighting
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- use vim highlighting in addition to treesitter
|
||||
additional_vim_regex_highlighting = true,
|
||||
|
||||
disable = function(lang, buf)
|
||||
-- disable in diff files
|
||||
local langs = { "diff" }
|
||||
if table.contains(langs, lang) then
|
||||
return true
|
||||
end
|
||||
|
||||
-- disable in big files
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
14
lua/conf/plugins/treesj.lua
Normal file
14
lua/conf/plugins/treesj.lua
Normal file
@ -0,0 +1,14 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'Wansmer/treesj',
|
||||
disable = vim.version().minor < 9,
|
||||
requires = 'nvim-treesitter/nvim-treesitter',
|
||||
function()
|
||||
require('treesj').setup {
|
||||
use_default_keymaps = false,
|
||||
}
|
||||
|
||||
map('n', '<leader>j', require('treesj').toggle, { desc = 'fold code' })
|
||||
end
|
||||
}
|
12
lua/conf/plugins/undotree.lua
Normal file
12
lua/conf/plugins/undotree.lua
Normal file
@ -0,0 +1,12 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
return { 'mbbill/undotree',
|
||||
function()
|
||||
if (vim.g.loaded_undotree) then
|
||||
vim.g.undotree_DiffAutoOpen = 0
|
||||
end
|
||||
|
||||
map("n", "<leader>u", "<cmd>UndotreeToggle<CR>")
|
||||
end
|
||||
}
|
Reference in New Issue
Block a user