a lot more stuff
This commit is contained in:
136
after/ftplugin/java.lua
Normal file
136
after/ftplugin/java.lua
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
local misc = require('core.misc')
|
||||||
|
local lsp = require('core.lsp.functions')
|
||||||
|
local map, auto = misc.map, misc.auto
|
||||||
|
|
||||||
|
local jdtls = require('jdtls')
|
||||||
|
local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path()
|
||||||
|
|
||||||
|
-- make sure to check if things with 💀 need updating
|
||||||
|
local config = {
|
||||||
|
cmd = {
|
||||||
|
'java', -- 💀
|
||||||
|
'-jar', vim.fn.glob(jdtls_install..'/plugins/org.eclipse.equinox.launcher_*.jar'), -- 💀
|
||||||
|
'-configuration', jdtls_install..'/config_linux',
|
||||||
|
'-data', vim.fn.stdpath('cache')..'/nvim-jdtls',
|
||||||
|
|
||||||
|
'--add-modules=ALL-SYSTEM',
|
||||||
|
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
|
||||||
|
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
|
||||||
|
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||||
|
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||||
|
'-Dlog.level=ALL',
|
||||||
|
'-Dlog.protocol=true',
|
||||||
|
'-Dosgi.bundles.defaultStartLevel=4',
|
||||||
|
'-Xmx1G',
|
||||||
|
},
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({
|
||||||
|
'gradlew',
|
||||||
|
'.git',
|
||||||
|
'mvnw',
|
||||||
|
'settings.gradle', -- Gradle (multi-project)
|
||||||
|
'settings.gradle.kts', -- Gradle (multi-project)
|
||||||
|
'build.xml', -- Ant
|
||||||
|
'pom.xml', -- Maven
|
||||||
|
}, { upward = true })[1]),
|
||||||
|
|
||||||
|
-- don't print out status messages
|
||||||
|
handlers = {
|
||||||
|
['language/status'] = function() end
|
||||||
|
},
|
||||||
|
|
||||||
|
on_attach = function(_, 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', function() jdtls.extract_variable(true) end, opts)
|
||||||
|
map('x', 'crc', function() jdtls.extract_constant(true) end, opts)
|
||||||
|
map('x', 'crm', function() jdtls.extract_method(true) end, opts)
|
||||||
|
|
||||||
|
pcall(vim.lsp.codelens.refresh)
|
||||||
|
auto('BufWritePost', {
|
||||||
|
buffer = bufnr,
|
||||||
|
desc = 'refresh codelens',
|
||||||
|
callback = function()
|
||||||
|
pcall(vim.lsp.codelens.refresh)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
capabilities = lsp.capabilities
|
||||||
|
}
|
||||||
|
|
||||||
|
-- generate the path to the java file(s)
|
||||||
|
---@type string|nil
|
||||||
|
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"), "/JavaVersion.class")
|
||||||
|
---@type string|nil
|
||||||
|
local src_path = vim.fs.joinpath(vim.fn.stdpath("config"), "/extras/JavaVersion.java")
|
||||||
|
|
||||||
|
-- if either path is invalid
|
||||||
|
if not cache_path or not src_path then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--- build a cache of the JavaVersion code
|
||||||
|
local function build_cache()
|
||||||
|
-- check if we have javac
|
||||||
|
vim.system({ "javac" }, {}, function(out)
|
||||||
|
if out.code == 127 then
|
||||||
|
cache_path = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- compile our code
|
||||||
|
vim.system({ 'javac', src_path, '-d', vim.fn.stdpath("cache") }, {}, function(out)
|
||||||
|
if out.code ~= 0 then
|
||||||
|
cache_path = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check if we have a compiled version of JavaVersion
|
||||||
|
local f, _ = io.open(cache_path, "r")
|
||||||
|
if not f then -- if we don't have a cache
|
||||||
|
build_cache()
|
||||||
|
else
|
||||||
|
io.close(f)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check the java version
|
||||||
|
local buffer = {}
|
||||||
|
vim.fn.jobstart({
|
||||||
|
config.cmd[1],
|
||||||
|
(cache_path and "JavaVersion") or src_path
|
||||||
|
}, {
|
||||||
|
cwd = vim.fn.stdpath("cache"),
|
||||||
|
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
|
||||||
|
|
||||||
|
-- start lsp
|
||||||
|
jdtls.start_or_attach(config)
|
||||||
|
end
|
||||||
|
})
|
@ -17,7 +17,7 @@ end, "so")
|
|||||||
-- if the parsers don't exist download them
|
-- if the parsers don't exist download them
|
||||||
if found[0] < 2 and
|
if found[0] < 2 and
|
||||||
(not found["norg.so"] or not found["norg_meta.so"]) then
|
(not found["norg.so"] or not found["norg_meta.so"]) then
|
||||||
vim.cmd.Neorg("sync-parsers")
|
vim.cmd("Neorg sync-parsers")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set colorcolumn in norg buffers
|
-- set colorcolumn in norg buffers
|
||||||
|
6
init.lua
6
init.lua
@ -1,12 +1,14 @@
|
|||||||
-- enable performance stuff
|
-- enable performance stuff
|
||||||
vim.loader.enable()
|
if vim.fn.has("nvim-0.9") == true then
|
||||||
|
vim.loader.enable()
|
||||||
|
end
|
||||||
|
|
||||||
-- bootstrap plugin manager
|
-- bootstrap plugin manager
|
||||||
local path = vim.fn.stdpath("data").."/site/pack/deps/opt/dep"
|
local path = vim.fn.stdpath("data").."/site/pack/deps/opt/dep"
|
||||||
if vim.fn.empty(vim.fn.glob(path)) > 0 then
|
if vim.fn.empty(vim.fn.glob(path)) > 0 then
|
||||||
vim.fn.system({ "git", "clone", "--depth=1", "https://git.squi.bid/dep", path })
|
vim.fn.system({ "git", "clone", "--depth=1", "https://git.squi.bid/dep", path })
|
||||||
end
|
end
|
||||||
vim.cmd.packadd("dep")
|
vim.cmd("packadd dep")
|
||||||
|
|
||||||
-- load miscellaneous utilities
|
-- load miscellaneous utilities
|
||||||
local misc = require('core.misc')
|
local misc = require('core.misc')
|
||||||
|
@ -24,7 +24,8 @@ auto('BufRead', {
|
|||||||
group = bufcheck,
|
group = bufcheck,
|
||||||
desc = 'Return to the last place the buffer was closed in.',
|
desc = 'Return to the last place the buffer was closed in.',
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd.call([[setpos(".", getpos("'\""))]])
|
vim.fn.setpos('.', vim.fn.getpos("'\""))
|
||||||
|
vim.cmd("norm! zz")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ vim.keymap.set('n', 'z=', function()
|
|||||||
end, { desc = 'Shows spelling suggestions' })
|
end, { desc = 'Shows spelling suggestions' })
|
||||||
|
|
||||||
-- quickfix
|
-- quickfix
|
||||||
map('n', '<M-j>', '<cmd>cnext<CR>zz')
|
map('n', '<M-j>', '<cmd>cnext<CR>')
|
||||||
map('n', '<M-k>', '<cmd>cprev<CR>zz')
|
map('n', '<M-k>', '<cmd>cprev<CR>')
|
||||||
map('n', '<M-c>', '<cmd>cclose<CR>')
|
map('n', '<M-c>', '<cmd>cclose<CR>')
|
||||||
|
|
||||||
-- open up Ex
|
-- man pages
|
||||||
map('n', '<leader>c', '<cmd>Ex<CR>')
|
map('n', '<C-k>', '<cmd>Man<CR>')
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
local misc = require('core.misc')
|
||||||
|
local auto = misc.auto
|
||||||
|
|
||||||
-- color stuff
|
-- color stuff
|
||||||
if vim.fn.has("termguicolors") then
|
if vim.fn.has("termguicolors") then
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
@ -5,6 +8,10 @@ end
|
|||||||
|
|
||||||
vim.opt.laststatus = 3
|
vim.opt.laststatus = 3
|
||||||
|
|
||||||
|
-- numbers
|
||||||
|
vim.opt.number = true
|
||||||
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
-- buffer
|
-- buffer
|
||||||
vim.opt.scrolloff = 5
|
vim.opt.scrolloff = 5
|
||||||
vim.opt.wrap = true -- wraping lines
|
vim.opt.wrap = true -- wraping lines
|
||||||
@ -21,7 +28,12 @@ vim.opt.tabstop = tabwidth
|
|||||||
vim.opt.shiftwidth = tabwidth
|
vim.opt.shiftwidth = tabwidth
|
||||||
vim.opt.softtabstop = tabwidth
|
vim.opt.softtabstop = tabwidth
|
||||||
|
|
||||||
vim.opt.clipboard = 'unnamedplus' -- system clipboard
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||||
|
-- (yoinked from kickstart.nvim)
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.opt.clipboard = 'unnamedplus' -- system clipboard
|
||||||
|
end)
|
||||||
|
|
||||||
vim.opt.updatetime = 200
|
vim.opt.updatetime = 200
|
||||||
|
|
||||||
-- file saving
|
-- file saving
|
||||||
@ -50,3 +62,71 @@ vim.g.netrw_winsize = 30
|
|||||||
vim.g.netrw_liststyle = 1
|
vim.g.netrw_liststyle = 1
|
||||||
vim.g.netrw_sizestyle = "H"
|
vim.g.netrw_sizestyle = "H"
|
||||||
vim.g.netrw_hide = 1
|
vim.g.netrw_hide = 1
|
||||||
|
|
||||||
|
-- folding
|
||||||
|
auto("FileType", {
|
||||||
|
callback = function()
|
||||||
|
-- support lsp folding
|
||||||
|
if vim.fn.has("nvim-0.11") then
|
||||||
|
auto('LspAttach', {
|
||||||
|
callback = function(args)
|
||||||
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
if not client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if client:supports_method('textDocument/foldingRange') then
|
||||||
|
local win = vim.api.nvim_get_current_win()
|
||||||
|
vim.wo[win][0].foldmethod = "expr"
|
||||||
|
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- or just rely on treesitter
|
||||||
|
if require("nvim-treesitter.parsers").has_parser() then
|
||||||
|
vim.opt.foldmethod = "expr"
|
||||||
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
|
else
|
||||||
|
vim.opt.foldmethod = "syntax"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- lsp folding: vim.o.foldexpr = "v:lua.vim.lsp.foldexpr()"
|
||||||
|
-- waiting on https://github.com/neovim/neovim/pull/31311 to hit a release
|
||||||
|
require('core.lsp.functions').add_capabilities({
|
||||||
|
textDocument = {
|
||||||
|
foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.opt.foldlevelstart = 99
|
||||||
|
vim.opt.foldlevel = 99
|
||||||
|
vim.opt.foldenable = true
|
||||||
|
vim.o.fillchars = 'fold: '
|
||||||
|
|
||||||
|
_G.Fold_text = require('core.folding')
|
||||||
|
vim.opt.foldtext = 'v:lua.Fold_text()'
|
||||||
|
|
||||||
|
-- statusline
|
||||||
|
function _G.Status()
|
||||||
|
return table.concat {
|
||||||
|
"%t", -- file name
|
||||||
|
" %h", -- help buffer tag
|
||||||
|
"%m", -- modify tag
|
||||||
|
"%r", -- readonly flag
|
||||||
|
"%=", -- seperate left and right side
|
||||||
|
|
||||||
|
-- print out the number of lsp clients attached
|
||||||
|
"λ"..#vim.lsp.get_clients({ bufnr = 0 }).." ",
|
||||||
|
|
||||||
|
"%l,%c%V", -- line, column-virtual column
|
||||||
|
" %P" -- percentage through display window
|
||||||
|
}
|
||||||
|
end
|
||||||
|
vim.o.statusline="%!v:lua.Status()"
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
|
local lsp = require('core.lsp.functions')
|
||||||
|
|
||||||
return { 'hrsh7th/nvim-cmp',
|
return { 'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
'lukas-reineke/cmp-under-comparator' -- better results
|
'lukas-reineke/cmp-under-comparator', -- better results
|
||||||
|
'xzbdmw/colorful-menu.nvim' -- fancy colors
|
||||||
},
|
},
|
||||||
|
|
||||||
-- suppliers for completions (they require nvim-cmp to be loaded before they are)
|
-- suppliers for completions (they require nvim-cmp to be loaded before they are)
|
||||||
deps = {
|
deps = {
|
||||||
'hrsh7th/cmp-buffer', -- buffers
|
'hrsh7th/cmp-buffer', -- buffers
|
||||||
'FelipeLema/cmp-async-path', -- path
|
'FelipeLema/cmp-async-path', -- path
|
||||||
'hrsh7th/cmp-nvim-lsp', -- lsp
|
{ 'hrsh7th/cmp-nvim-lsp',
|
||||||
|
function()
|
||||||
|
-- add lsp capabilities
|
||||||
|
lsp.add_capabilities(require('cmp_nvim_lsp').default_capabilities())
|
||||||
|
end
|
||||||
|
}, -- lsp
|
||||||
'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information
|
'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information
|
||||||
{ 'L3MON4D3/cmp-luasnip-choice', -- luasnip
|
{ 'L3MON4D3/cmp-luasnip-choice', -- luasnip
|
||||||
requires = 'L3MON4D3/LuaSnip'
|
requires = 'L3MON4D3/LuaSnip'
|
||||||
@ -19,6 +27,7 @@ return { 'hrsh7th/nvim-cmp',
|
|||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
|
|
||||||
|
-- setup cmp
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
-- disable when in comments
|
-- disable when in comments
|
||||||
enabled = function()
|
enabled = function()
|
||||||
@ -44,8 +53,8 @@ return { 'hrsh7th/nvim-cmp',
|
|||||||
-- how to sort results
|
-- how to sort results
|
||||||
sorting = {
|
sorting = {
|
||||||
comparators = {
|
comparators = {
|
||||||
cmp.config.compare.offset,
|
|
||||||
cmp.config.compare.exact,
|
cmp.config.compare.exact,
|
||||||
|
cmp.config.compare.offset,
|
||||||
cmp.config.compare.score,
|
cmp.config.compare.score,
|
||||||
require('cmp-under-comparator').under,
|
require('cmp-under-comparator').under,
|
||||||
cmp.config.compare.kind,
|
cmp.config.compare.kind,
|
||||||
@ -80,16 +89,24 @@ return { 'hrsh7th/nvim-cmp',
|
|||||||
formatting = {
|
formatting = {
|
||||||
fields = { 'menu', 'abbr', 'kind' },
|
fields = { 'menu', 'abbr', 'kind' },
|
||||||
format = function(entry, item)
|
format = function(entry, item)
|
||||||
|
local hl_info = require("colorful-menu").cmp_highlights(entry)
|
||||||
local menu_icon = {
|
local menu_icon = {
|
||||||
nvim_lsp = 'λ',
|
nvim_lsp = 'λ',
|
||||||
nvim_lua = 'v',
|
|
||||||
luasnip = '%',
|
luasnip = '%',
|
||||||
buffer = '@',
|
buffer = '@',
|
||||||
path = '#',
|
path = '#',
|
||||||
async_path = '#'
|
async_path = '#'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- add a little icon
|
||||||
item.menu = menu_icon[entry.source.name]
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
|
||||||
|
-- add highlights
|
||||||
|
if hl_info ~= nil then
|
||||||
|
item.abbr_hl_group = hl_info.highlights
|
||||||
|
item.abbr = hl_info.text
|
||||||
|
end
|
||||||
|
|
||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
@ -107,25 +124,14 @@ return { 'hrsh7th/nvim-cmp',
|
|||||||
|
|
||||||
-- mappings
|
-- mappings
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
["<C-y>"] = cmp.mapping(function()
|
["<C-y>"] = cmp.mapping.confirm {
|
||||||
cmp.confirm({ select = true })
|
select = true
|
||||||
end, { "i", "c" }),
|
},
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
["<C-n>"] = cmp.mapping(function()
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
|
|
||||||
["<C-p>"] = cmp.mapping(function()
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
end
|
|
||||||
end),
|
|
||||||
|
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||||
['<ESC>'] = cmp.mapping.close()
|
["<ESC>"] = cmp.mapping.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
return { 'theHamsta/nvim-dap-virtual-text',
|
|
||||||
requires = {
|
|
||||||
'mfussenegger/nvim-dap',
|
|
||||||
'nvim-treesitter/nvim-treesitter'
|
|
||||||
},
|
|
||||||
function()
|
|
||||||
require("nvim-dap-virtual-text").setup {}
|
|
||||||
end
|
|
||||||
}
|
|
@ -4,9 +4,9 @@ local map = misc.map
|
|||||||
return { 'mfussenegger/nvim-dap',
|
return { 'mfussenegger/nvim-dap',
|
||||||
requires = {
|
requires = {
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
'nvim-telescope/telescope.nvim'
|
'nvim-telescope/telescope.nvim',
|
||||||
},
|
},
|
||||||
disable = vim.version().minor < 8,
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
branch = '0.8.0',
|
branch = '0.8.0',
|
||||||
function()
|
function()
|
||||||
|
|
||||||
@ -38,10 +38,13 @@ return { 'mfussenegger/nvim-dap',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map('n', '<Leader>ec', dap.continue)
|
map('n', '<Leader>ec', dap.continue, { desc = "dap continue " })
|
||||||
map('n', '<Leader>eb', require("dap.breakpoints").toggle)
|
map('n', '<Leader>el', dap.run_last, { desc = "dap run last" })
|
||||||
map('n', '<Leader>e]', dap.step_over)
|
map('n', '<Leader>et', dap.terminate, { desc = "dap terminate " })
|
||||||
map('n', '<Leader>e[', dap.step_back)
|
map('n', '<Leader>eb', require("dap.breakpoints").toggle, { desc = "dap toggle breakpoint" })
|
||||||
map('n', '<Leader>eR', dap.restart)
|
map('n', '<Leader>e]', dap.step_over, { desc = "dap step over" })
|
||||||
|
map('n', '<Leader>e[', dap.step_back, { desc = "dap step back" })
|
||||||
|
map('n', '<Leader>er', dap.repl.toggle, { desc = "dap repl toggle" })
|
||||||
|
map('n', '<Leader>eR', dap.restart, { desc = "dap restart" })
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
local branch = nil
|
local branch = nil
|
||||||
if vim.version().minor == 7 then
|
if vim.fn.has("nvim-0.7.0") then
|
||||||
branch = 'nvim-0.7'
|
branch = 'nvim-0.7'
|
||||||
elseif vim.version().minor == 5 then
|
elseif vim.fn.has("nvim-0.5.0") then
|
||||||
branch = 'nvim-0.5'
|
branch = 'nvim-0.5'
|
||||||
end
|
end
|
||||||
|
|
||||||
return { 'stevearc/dressing.nvim',
|
return { 'stevearc/dressing.nvim',
|
||||||
disable = vim.version().minor < 5,
|
disable = true or not vim.fn.has("nvim-0.5.0"),
|
||||||
branch = branch,
|
branch = branch,
|
||||||
requires = 'nvim-telescope/telescope.nvim',
|
requires = 'nvim-telescope/telescope.nvim',
|
||||||
function()
|
function()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
return { 'j-hui/fidget.nvim',
|
return { 'j-hui/fidget.nvim',
|
||||||
disable = vim.version().minor < 9,
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
branch = "v1.5.0",
|
branch = "v1.5.0",
|
||||||
function()
|
function()
|
||||||
local notification_defaults = require("fidget.notification").default_config
|
local notification_defaults = require("fidget.notification").default_config
|
||||||
@ -16,6 +16,7 @@ return { 'j-hui/fidget.nvim',
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
notification = {
|
notification = {
|
||||||
|
filter = vim.log.levels.DEBUG,
|
||||||
override_vim_notify = true,
|
override_vim_notify = true,
|
||||||
configs = {
|
configs = {
|
||||||
default = notification_defaults
|
default = notification_defaults
|
||||||
|
@ -2,7 +2,7 @@ local misc = require('core.misc')
|
|||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
return { 'lewis6991/gitsigns.nvim',
|
return { 'lewis6991/gitsigns.nvim',
|
||||||
disable = vim.version().minor < 9,
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
function()
|
function()
|
||||||
local gs = require("gitsigns")
|
local gs = require("gitsigns")
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ local misc = require('core.misc')
|
|||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
return { 'ThePrimeagen/harpoon',
|
return { 'ThePrimeagen/harpoon',
|
||||||
disable = vim.version().minor < 8,
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
commit = 'e76cb03',
|
commit = 'e76cb03',
|
||||||
branch = 'harpoon2',
|
branch = 'harpoon2',
|
||||||
requires = 'nvim-lua/plenary.nvim',
|
requires = 'nvim-lua/plenary.nvim',
|
||||||
|
@ -14,14 +14,7 @@ return { 'lukas-reineke/headlines.nvim',
|
|||||||
bullets = { "", "", "", "" },
|
bullets = { "", "", "", "" },
|
||||||
},
|
},
|
||||||
markdown = {
|
markdown = {
|
||||||
headline_highlights = {
|
headline_highlights = false
|
||||||
"@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
|
end
|
||||||
|
5
lua/conf/plugins/instant.lua
Normal file
5
lua/conf/plugins/instant.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
return { 'jbyuki/instant.nvim',
|
||||||
|
function()
|
||||||
|
vim.g.instant_username = "squibid"
|
||||||
|
end
|
||||||
|
}
|
@ -3,7 +3,7 @@ local lsp = require('core.lsp.functions')
|
|||||||
local map, auto = misc.map, misc.auto
|
local map, auto = misc.map, misc.auto
|
||||||
|
|
||||||
return { 'mfussenegger/nvim-jdtls',
|
return { 'mfussenegger/nvim-jdtls',
|
||||||
disable = vim.version().minor < 6,
|
disable = not vim.fn.has("nvim-0.6.0"),
|
||||||
requires = 'mfussenegger/nvim-dap',
|
requires = 'mfussenegger/nvim-dap',
|
||||||
function()
|
function()
|
||||||
auto("FileType", {
|
auto("FileType", {
|
||||||
@ -34,7 +34,10 @@ return { 'mfussenegger/nvim-jdtls',
|
|||||||
'gradlew',
|
'gradlew',
|
||||||
'.git',
|
'.git',
|
||||||
'mvnw',
|
'mvnw',
|
||||||
'build.xml'
|
'settings.gradle', -- Gradle (multi-project)
|
||||||
|
'settings.gradle.kts', -- Gradle (multi-project)
|
||||||
|
'build.xml', -- Ant
|
||||||
|
'pom.xml', -- Maven
|
||||||
}, { upward = true })[1]),
|
}, { upward = true })[1]),
|
||||||
|
|
||||||
-- don't print out status messages
|
-- don't print out status messages
|
||||||
@ -42,10 +45,7 @@ return { 'mfussenegger/nvim-jdtls',
|
|||||||
['language/status'] = function() end
|
['language/status'] = function() end
|
||||||
},
|
},
|
||||||
|
|
||||||
capabilities = lsp.capabilities(),
|
on_attach = function(_, bufnr)
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
lsp.attach(client, bufnr)
|
|
||||||
|
|
||||||
-- add some jdtls specific mappings
|
-- add some jdtls specific mappings
|
||||||
local opts = { buffer = bufnr }
|
local opts = { buffer = bufnr }
|
||||||
map('n', 'cri', jdtls.organize_imports, opts)
|
map('n', 'cri', jdtls.organize_imports, opts)
|
||||||
@ -64,8 +64,10 @@ return { 'mfussenegger/nvim-jdtls',
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
capabilities = lsp.capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- generate the path to the java file(s)
|
||||||
---@type string|nil
|
---@type string|nil
|
||||||
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"), "/JavaVersion.class")
|
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"), "/JavaVersion.class")
|
||||||
---@type string|nil
|
---@type string|nil
|
||||||
|
@ -7,7 +7,7 @@ return { 'kawre/leetcode.nvim',
|
|||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
-- because we're using treesitter make sure to install the html parser
|
-- because we're using treesitter make sure to install the html parser
|
||||||
vim.cmd.TSUpdate("html")
|
vim.cmd("TSUpdate html")
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
require('leetcode').setup {
|
require('leetcode').setup {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
return { 'whynothugo/lsp_lines',
|
return { 'whynothugo/lsp_lines',
|
||||||
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim'
|
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim',
|
||||||
|
disable = not vim.fn.has("nvim-0.8.0")
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ local map = misc.map
|
|||||||
|
|
||||||
return { 'L3MON4D3/LuaSnip',
|
return { 'L3MON4D3/LuaSnip',
|
||||||
branch = 'v2.3.0',
|
branch = 'v2.3.0',
|
||||||
disable = vim.version().minor < 7,
|
disable = not vim.fn.has("nvim-0.7.0"),
|
||||||
config = function()
|
config = function()
|
||||||
vim.cmd.make('install_jsregexp')
|
vim.cmd('make install_jsregexp')
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
local misc = require('core.misc')
|
local misc = require('core.misc')
|
||||||
local lsp = require('core.lsp.functions')
|
local lsp = require('core.lsp.functions')
|
||||||
local map, auto, augroup = misc.map, misc.auto, misc.augroup
|
local map = misc.map
|
||||||
|
|
||||||
return { 'williamboman/mason-lspconfig.nvim',
|
return { 'williamboman/mason-lspconfig.nvim',
|
||||||
requires = {
|
requires = {
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
{ 'neovim/nvim-lspconfig',
|
{ 'neovim/nvim-lspconfig',
|
||||||
disable = vim.version().minor < 8,
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
function()
|
function()
|
||||||
lsp.setup()
|
lsp.setup()
|
||||||
end
|
end
|
||||||
}
|
},
|
||||||
|
|
||||||
|
-- these two update some lsp capabilities and therefore must be run first
|
||||||
|
-- 'hrsh7th/cmp-nvim-lsp',
|
||||||
|
-- 'kevinhwang91/nvim-ufo'
|
||||||
},
|
},
|
||||||
function()
|
function()
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
local util = require('lspconfig.util')
|
local util = require('lspconfig.util')
|
||||||
|
|
||||||
-- setup language servers
|
-- setup language servers
|
||||||
@ -27,97 +32,105 @@ return { 'williamboman/mason-lspconfig.nvim',
|
|||||||
"bashls",
|
"bashls",
|
||||||
"zls"
|
"zls"
|
||||||
-- "asm-lsp", -- seems to be broken
|
-- "asm-lsp", -- seems to be broken
|
||||||
}
|
},
|
||||||
}
|
|
||||||
require('mason-lspconfig').setup_handlers {
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup {
|
|
||||||
on_attach = lsp.lsp_attach,
|
|
||||||
capabilities = lsp.capabilities()
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- setup luals
|
-- setup all handlers
|
||||||
["lua_ls"] = function(server_name)
|
handlers = {
|
||||||
local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc',
|
function(server_name)
|
||||||
'.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml',
|
lspconfig[server_name].setup {}
|
||||||
'README.md'
|
end,
|
||||||
}
|
|
||||||
|
|
||||||
-- FIXME: luals seems to start up twice and sends back twice the
|
-- setup luals
|
||||||
-- completions (one configured with the below settings and one without)
|
["lua_ls"] = function(server_name)
|
||||||
require('lspconfig')[server_name].setup {
|
local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc',
|
||||||
on_attach = lsp.attach,
|
'.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml',
|
||||||
capabilities = lsp.capabilities(),
|
'README.md'
|
||||||
settings = {
|
}
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
-- FIXME: luals seems to start up twice and sends back twice the
|
||||||
globals = { "vim", 'mp' }
|
-- completions (one configured with the below settings and one without)
|
||||||
},
|
lspconfig[server_name].setup {
|
||||||
runtime = {
|
settings = {
|
||||||
version = 'LuaJIT'
|
Lua = {
|
||||||
},
|
diagnostics = {
|
||||||
format = {
|
globals = { "vim", 'mp' }
|
||||||
enable = false
|
},
|
||||||
},
|
runtime = {
|
||||||
workspace = {
|
version = 'LuaJIT'
|
||||||
checkThirdParty = false,
|
},
|
||||||
library = {
|
format = {
|
||||||
vim.env.VIMRUNTIME
|
enable = false
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
library = {
|
||||||
|
vim.env.VIMRUNTIME
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
|
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
local root = util.root_pattern(unpack(root_files))(fname)
|
local root = util.root_pattern(unpack(root_files))(fname)
|
||||||
if root and root ~= vim.env.HOME then
|
if root and root ~= vim.env.HOME then
|
||||||
return root
|
return root
|
||||||
|
end
|
||||||
|
|
||||||
|
root = util.root_pattern('lua/')(fname)
|
||||||
|
if root then
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
return util.find_git_ancestor(fname)
|
||||||
end
|
end
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
|
||||||
root = util.root_pattern('lua/')(fname)
|
-- setup clangd
|
||||||
if root then
|
["clangd"] = function(server_name)
|
||||||
return root
|
lspconfig[server_name].setup {
|
||||||
end
|
on_attach = function(client, bufnr)
|
||||||
return util.find_git_ancestor(fname)
|
-- add some clangd specific mappings
|
||||||
end
|
local opts = { buffer = bufnr }
|
||||||
}
|
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- setup clangd
|
cmd = {
|
||||||
["clangd"] = function(server_name)
|
"clangd",
|
||||||
require('lspconfig')[server_name].setup {
|
"--background-index",
|
||||||
on_attach = function(client, bufnr)
|
"--clang-tidy",
|
||||||
lsp.attach(client, bufnr)
|
"--header-insertion=iwyu",
|
||||||
|
"--completion-style=detailed",
|
||||||
-- add some clangd specific mappings
|
"--function-arg-placeholders",
|
||||||
local opts = { buffer = bufnr }
|
"--fallback-style=llvm"
|
||||||
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
},
|
||||||
end,
|
init_options = {
|
||||||
capabilities = lsp.capabilities(),
|
usePlaceholders = true,
|
||||||
|
clangdFileStatus = true,
|
||||||
cmd = {
|
fallback_flags = {
|
||||||
"clangd",
|
"-xc" -- makes clangd think we're using c instead of c++
|
||||||
"--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,
|
||||||
end,
|
|
||||||
|
|
||||||
-- disable it, we start this using nvim-jdtls
|
-- disable it, we start this using nvim-jdtls
|
||||||
["jdtls"] = function(_) end
|
["jdtls"] = function(_) end,
|
||||||
|
|
||||||
|
-- setup basedpyright
|
||||||
|
["basedpyright"] = function(server_name)
|
||||||
|
lspconfig[server_name].setup {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
-- add some basedpyright specific mappings
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
map("n", "cri", "<cmd>PyrightOrganizeImports<CR>", opts)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
|
["openscad_lsp"] = function(server_name)
|
||||||
|
lspconfig[server_name].setup {}
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
return { 'williamboman/mason.nvim',
|
return { 'williamboman/mason.nvim',
|
||||||
disable = vim.version().minor < 7,
|
disable = not vim.fn.has("nvim-0.7.0"),
|
||||||
function()
|
function()
|
||||||
local mason = require('mason')
|
local mason = require('mason')
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
return { 'mellow-theme/mellow.nvim',
|
return { 'mellow-theme/mellow.nvim',
|
||||||
disable = vim.version().minor < 8,
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
requires = 'nvim-treesitter/nvim-treesitter',
|
requires = 'nvim-treesitter/nvim-treesitter',
|
||||||
function()
|
function()
|
||||||
vim.g.mellow_variant = "dark"
|
vim.g.mellow_variant = "dark"
|
||||||
|
52
lua/conf/plugins/mini-clue.lua
Normal file
52
lua/conf/plugins/mini-clue.lua
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
return { 'echasnovski/mini.clue',
|
||||||
|
disable = true,
|
||||||
|
-- disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
|
branch = "stable",
|
||||||
|
function()
|
||||||
|
local miniclue = require('mini.clue')
|
||||||
|
miniclue.setup({
|
||||||
|
triggers = {
|
||||||
|
-- Leader triggers
|
||||||
|
{ mode = 'n', keys = '<Leader>' },
|
||||||
|
{ mode = 'x', keys = '<Leader>' },
|
||||||
|
|
||||||
|
-- Built-in completion
|
||||||
|
{ mode = 'i', keys = '<C-x>' },
|
||||||
|
|
||||||
|
-- `g` key
|
||||||
|
{ mode = 'n', keys = 'g' },
|
||||||
|
{ mode = 'x', keys = 'g' },
|
||||||
|
|
||||||
|
-- Marks
|
||||||
|
{ mode = 'n', keys = "'" },
|
||||||
|
{ mode = 'n', keys = '`' },
|
||||||
|
{ mode = 'x', keys = "'" },
|
||||||
|
{ mode = 'x', keys = '`' },
|
||||||
|
|
||||||
|
-- Registers
|
||||||
|
{ mode = 'n', keys = '"' },
|
||||||
|
{ mode = 'x', keys = '"' },
|
||||||
|
{ mode = 'i', keys = '<C-r>' },
|
||||||
|
{ mode = 'c', keys = '<C-r>' },
|
||||||
|
|
||||||
|
-- Window commands
|
||||||
|
{ mode = 'n', keys = '<C-w>' },
|
||||||
|
|
||||||
|
-- `z` key
|
||||||
|
{ mode = 'n', keys = 'z' },
|
||||||
|
{ mode = 'x', keys = 'z' },
|
||||||
|
},
|
||||||
|
|
||||||
|
clues = {
|
||||||
|
-- Enhance this by adding descriptions for <Leader> mapping groups
|
||||||
|
miniclue.gen_clues.builtin_completion(),
|
||||||
|
miniclue.gen_clues.g(),
|
||||||
|
miniclue.gen_clues.marks(),
|
||||||
|
miniclue.gen_clues.registers(),
|
||||||
|
miniclue.gen_clues.windows(),
|
||||||
|
miniclue.gen_clues.z(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
}
|
@ -8,7 +8,12 @@
|
|||||||
-- dependencies take a look at the build.lua for versioning info. Also make sure
|
-- 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.
|
-- 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")
|
local workspace_cache
|
||||||
|
if not vim.fs then
|
||||||
|
workspace_cache = vim.fn.stdpath("data").."/neorg-workspace-cache.lua"
|
||||||
|
else
|
||||||
|
workspace_cache = vim.fs.joinpath(vim.fn.stdpath("data"), "neorg-workspace-cache.lua")
|
||||||
|
end
|
||||||
|
|
||||||
--- populate neorg workspaces from path or cache
|
--- populate neorg workspaces from path or cache
|
||||||
---@param path string path to populate workspaces from
|
---@param path string path to populate workspaces from
|
||||||
@ -57,8 +62,8 @@ local function populate_workspaces(path, cache)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return { 'nvim-neorg/neorg',
|
return { 'nvim-neorg/neorg',
|
||||||
disable = vim.version.lt(vim.version(), { 0, 10, 0 }),
|
disable = not vim.fn.has("nvim-0.10.0"),
|
||||||
branch = 'v9.1.1',
|
branch = 'v9.3.0',
|
||||||
requires = {
|
requires = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
@ -69,7 +74,8 @@ return { 'nvim-neorg/neorg',
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- NOTE: these are usually installed by neorg via luarocks, the versions
|
-- 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
|
-- were picked based on the neorg-scm-1.rockspec found in the root of the
|
||||||
|
-- neorg repo
|
||||||
{ 'nvim-neotest/nvim-nio',
|
{ 'nvim-neotest/nvim-nio',
|
||||||
branch = 'v1.7.0'
|
branch = 'v1.7.0'
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
return { 'norcalli/nvim-colorizer.lua',
|
return { 'norcalli/nvim-colorizer.lua',
|
||||||
disable = vim.version().minor < 4 and not vim.fn.has("termguicolors"),
|
disable = not vim.fn.has("nvim-0.4.0") and not vim.fn.has("termguicolors"),
|
||||||
function()
|
function()
|
||||||
require('colorizer').setup(nil, {
|
require('colorizer').setup(nil, {
|
||||||
names = false,
|
names = false,
|
||||||
|
7
lua/conf/plugins/nyooom.lua
Normal file
7
lua/conf/plugins/nyooom.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
return { 'squibid/nyooom',
|
||||||
|
url = 'https://git.squi.bid/nyooom',
|
||||||
|
pin = true,
|
||||||
|
function()
|
||||||
|
require('nyooom').setup {}
|
||||||
|
end
|
||||||
|
}
|
160
lua/conf/plugins/oil.lua
Normal file
160
lua/conf/plugins/oil.lua
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
local misc = require('core.misc')
|
||||||
|
local map = misc.map
|
||||||
|
|
||||||
|
local permission_hlgroups = {
|
||||||
|
['-'] = 'NonText',
|
||||||
|
['r'] = 'DiagnosticSignWarn',
|
||||||
|
['w'] = 'DiagnosticSignHint',
|
||||||
|
['x'] = 'DiagnosticSignOk',
|
||||||
|
}
|
||||||
|
|
||||||
|
return { 'stevearc/oil.nvim',
|
||||||
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
|
function()
|
||||||
|
require("oil").setup {
|
||||||
|
-- ID is automatically added at the beginning, and name at the end
|
||||||
|
-- See :help oil-columns
|
||||||
|
columns = {
|
||||||
|
{
|
||||||
|
"permissions",
|
||||||
|
highlight = function(permission_str)
|
||||||
|
local hls = {}
|
||||||
|
for i = 1, #permission_str do
|
||||||
|
local char = permission_str:sub(i, i)
|
||||||
|
table.insert(hls, { permission_hlgroups[char], i - 1, i })
|
||||||
|
end
|
||||||
|
return hls
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ "size", highlight = '@number' }
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Window-local options to use for oil buffers
|
||||||
|
win_options = {
|
||||||
|
number = false,
|
||||||
|
relativenumber = false,
|
||||||
|
wrap = false,
|
||||||
|
signcolumn = "no",
|
||||||
|
cursorcolumn = false,
|
||||||
|
foldcolumn = "0",
|
||||||
|
spell = false,
|
||||||
|
list = false,
|
||||||
|
conceallevel = 3,
|
||||||
|
concealcursor = "nvic"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
|
||||||
|
delete_to_trash = false,
|
||||||
|
|
||||||
|
-- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits)
|
||||||
|
skip_confirm_for_simple_edits = false,
|
||||||
|
|
||||||
|
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
|
||||||
|
-- (:help prompt_save_on_select_new_entry)
|
||||||
|
prompt_save_on_select_new_entry = true,
|
||||||
|
|
||||||
|
-- Oil will automatically delete hidden buffers after this delay
|
||||||
|
-- You can set the delay to false to disable cleanup entirely
|
||||||
|
-- Note that the cleanup process only starts when none of the oil buffers are currently displayed
|
||||||
|
cleanup_delay_ms = 2000,
|
||||||
|
lsp_file_methods = {
|
||||||
|
-- Enable or disable LSP file operations
|
||||||
|
enabled = true,
|
||||||
|
-- Time to wait for LSP file operations to complete before skipping
|
||||||
|
timeout_ms = 1000,
|
||||||
|
-- Set to true to autosave buffers that are updated with LSP willRenameFiles
|
||||||
|
-- Set to "unmodified" to only save unmodified buffers
|
||||||
|
autosave_changes = "unmodified"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Constrain the cursor to the editable parts of the oil buffer
|
||||||
|
-- Set to `false` to disable, or "name" to keep it on the file names
|
||||||
|
constrain_cursor = "editable",
|
||||||
|
|
||||||
|
-- Set to true to watch the filesystem for changes and reload oil
|
||||||
|
watch_for_changes = false,
|
||||||
|
|
||||||
|
-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
|
||||||
|
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" })
|
||||||
|
-- Additionally, if it is a string that matches "actions.<name>",
|
||||||
|
-- it will use the mapping at require("oil.actions").<name>
|
||||||
|
-- Set to `false` to remove a keymap
|
||||||
|
-- See :help oil-actions for a list of all available actions
|
||||||
|
keymaps = {
|
||||||
|
["g?"] = { "actions.show_help", mode = "n" },
|
||||||
|
["<C-l>"] = "actions.refresh",
|
||||||
|
["<CR>"] = "actions.select",
|
||||||
|
["-"] = { "actions.parent", mode = "n" },
|
||||||
|
["_"] = { "actions.open_cwd", mode = "n" },
|
||||||
|
["`"] = { "actions.cd", mode = "n" },
|
||||||
|
["~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" },
|
||||||
|
["gs"] = { "actions.change_sort", mode = "n" },
|
||||||
|
["gx"] = "actions.open_external",
|
||||||
|
["g."] = { "actions.toggle_hidden", mode = "n" },
|
||||||
|
["g\\"] = { "actions.toggle_trash", mode = "n" }
|
||||||
|
},
|
||||||
|
|
||||||
|
view_options = {
|
||||||
|
-- Show files and directories that start with "."
|
||||||
|
show_hidden = false,
|
||||||
|
|
||||||
|
-- This function defines what is considered a "hidden" file
|
||||||
|
is_hidden_file = function(name, bufnr)
|
||||||
|
if name == ".." then -- show previous directory
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local m = name:match("^%.")
|
||||||
|
return m ~= nil
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- This function defines what will never be shown, even when `show_hidden` is set
|
||||||
|
is_always_hidden = function(name, bufnr)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- Sort file names with numbers in a more intuitive order for humans.
|
||||||
|
-- Can be "fast", true, or false. "fast" will turn it off for large directories.
|
||||||
|
natural_order = "fast",
|
||||||
|
|
||||||
|
-- Sort file and directory names case insensitive
|
||||||
|
case_insensitive = false,
|
||||||
|
|
||||||
|
sort = {
|
||||||
|
-- sort order can be "asc" or "desc"
|
||||||
|
-- see :help oil-columns to see which columns are sortable
|
||||||
|
{ "type", "asc" },
|
||||||
|
{ "name", "asc" },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Customize the highlight group for the file name
|
||||||
|
highlight_filename = function(entry, is_hidden, is_link_target, is_link_orphan)
|
||||||
|
return nil
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Configuration for the floating window in oil.open_float
|
||||||
|
float = {
|
||||||
|
border = "solid"
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Configuration for the floating action confirmation window
|
||||||
|
confirmation = {
|
||||||
|
border = "solid"
|
||||||
|
},
|
||||||
|
-- Configuration for the floating progress window
|
||||||
|
progress = {
|
||||||
|
border = "solid"
|
||||||
|
},
|
||||||
|
-- Configuration for the floating SSH window
|
||||||
|
ssh = {
|
||||||
|
border = "solid"
|
||||||
|
},
|
||||||
|
-- Configuration for the floating keymaps help window
|
||||||
|
keymaps_help = {
|
||||||
|
border = "solid"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
map('n', '-', '<cmd>Oil<CR>')
|
||||||
|
end
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
return { 'ahmedkhalf/project.nvim',
|
return { 'ahmedkhalf/project.nvim',
|
||||||
disable = vim.version().minor < 5,
|
disable = true,
|
||||||
|
-- disable = vim.fn.has("nvim-0.5.0"),
|
||||||
function()
|
function()
|
||||||
require('project_nvim').setup {
|
require('project_nvim').setup {
|
||||||
patterns = {
|
patterns = {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
-- yea it's a bit flashy, but it's genuenly useful to be able to tell where my
|
|
||||||
-- cursor has gone
|
|
||||||
return { 'sphamba/smear-cursor.nvim',
|
|
||||||
disable = vim.version.lt(vim.version(), { 0, 10, 2 }) or vim.g.neovide_version,
|
|
||||||
function()
|
|
||||||
require('smear_cursor').setup {
|
|
||||||
stiffness = 0.8, -- 0.6 [0, 1]
|
|
||||||
trailing_stiffness = 0.5, -- 0.3 [0, 1]
|
|
||||||
distance_stop_animating = 0.5, -- 0.1 > 0
|
|
||||||
hide_target_hack = false -- true boolean
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
@ -2,12 +2,12 @@ local misc = require('core.misc')
|
|||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
return { 'nvim-telescope/telescope.nvim',
|
return { 'nvim-telescope/telescope.nvim',
|
||||||
disable = vim.version().minor < 9,
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
requires = {
|
requires = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
vim.cmd.make()
|
vim.cmd("make")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -48,14 +48,8 @@ return { 'nvim-telescope/telescope.nvim',
|
|||||||
["<esc>"] = actions.close,
|
["<esc>"] = actions.close,
|
||||||
['<C-j>'] = actions.move_selection_next,
|
['<C-j>'] = actions.move_selection_next,
|
||||||
['<C-k>'] = actions.move_selection_previous,
|
['<C-k>'] = actions.move_selection_previous,
|
||||||
['<C-l>'] = actions.select_default,
|
|
||||||
['<C-u>'] = actions.preview_scrolling_up,
|
['<C-u>'] = actions.preview_scrolling_up,
|
||||||
['<C-d>'] = actions.preview_scrolling_down,
|
['<C-d>'] = actions.preview_scrolling_down,
|
||||||
["<C-p>"] = action_layout.toggle_preview
|
|
||||||
},
|
|
||||||
n = {
|
|
||||||
["gg"] = actions.move_to_top,
|
|
||||||
["G"] = actions.move_to_bottom,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -77,7 +71,7 @@ return { 'nvim-telescope/telescope.nvim',
|
|||||||
desc = 'Find string in current buffer.',
|
desc = 'Find string in current buffer.',
|
||||||
})
|
})
|
||||||
map('n', '<leader>i', telebuilt.help_tags, {
|
map('n', '<leader>i', telebuilt.help_tags, {
|
||||||
desc = 'Fuzzy find over help tags.',
|
desc = 'find help tags.',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- find over specific directories
|
-- find over specific directories
|
||||||
@ -85,12 +79,12 @@ return { 'nvim-telescope/telescope.nvim',
|
|||||||
require('telescope.builtin').find_files {
|
require('telescope.builtin').find_files {
|
||||||
cwd = vim.fn.stdpath("config")
|
cwd = vim.fn.stdpath("config")
|
||||||
}
|
}
|
||||||
end, { desc = "Fuzzy find over files in my config" })
|
end, { desc = "find config files" })
|
||||||
map('n', '<leader>tp', function()
|
map('n', '<leader>tp', function()
|
||||||
require('telescope.builtin').find_files {
|
require('telescope.builtin').find_files {
|
||||||
cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "site/pack/deps/opt")
|
cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "site/pack/deps/opt")
|
||||||
}
|
}
|
||||||
end, { desc = "Fuzzy find over files in my plugin directory" })
|
end, { desc = "find files in plugin directory" })
|
||||||
|
|
||||||
-- enable previewing in the default colorscheme switcher
|
-- enable previewing in the default colorscheme switcher
|
||||||
telebuilt.colorscheme = function()
|
telebuilt.colorscheme = function()
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
local branch = nil
|
|
||||||
if vim.version().minor < 8 then
|
|
||||||
branch = 'neovim-pre-0.8.0'
|
|
||||||
end
|
|
||||||
|
|
||||||
return { 'folke/todo-comments.nvim',
|
return { 'folke/todo-comments.nvim',
|
||||||
requires = 'nvim-lua/plenary.nvim',
|
requires = 'nvim-lua/plenary.nvim',
|
||||||
branch = branch,
|
disable = not vim.fn.has("nvim-0.8.0"),
|
||||||
function()
|
function()
|
||||||
require('todo-comments').setup {
|
require('todo-comments').setup {
|
||||||
keywords = {
|
keywords = {
|
||||||
|
@ -8,9 +8,9 @@ table.contains = function(self, string)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return { 'nvim-treesitter/nvim-treesitter',
|
return { 'nvim-treesitter/nvim-treesitter',
|
||||||
disable = vim.version().minor < 10,
|
disable = not vim.fn.has("nvim-0.10.0"),
|
||||||
config = function()
|
config = function()
|
||||||
vim.cmd.TSUpdate()
|
vim.cmd("TSUpdate")
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
|
@ -2,7 +2,7 @@ local misc = require('core.misc')
|
|||||||
local map = misc.map
|
local map = misc.map
|
||||||
|
|
||||||
return { 'Wansmer/treesj',
|
return { 'Wansmer/treesj',
|
||||||
disable = vim.version().minor < 9,
|
disable = not vim.fn.has("nvim-0.9.0"),
|
||||||
requires = 'nvim-treesitter/nvim-treesitter',
|
requires = 'nvim-treesitter/nvim-treesitter',
|
||||||
function()
|
function()
|
||||||
require('treesj').setup {
|
require('treesj').setup {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
return { 'windwp/nvim-ts-autotag',
|
return { 'windwp/nvim-ts-autotag',
|
||||||
requires = 'nvim-telescope/telescope.nvim',
|
requires = {
|
||||||
disable = vim.version.lt(vim.version(), { 0, 9, 5 }),
|
'nvim-telescope/telescope.nvim',
|
||||||
|
'nvim-treesitter/nvim-treesitter'
|
||||||
|
},
|
||||||
|
disable = not vim.fn.has("nvim-0.9.5"),
|
||||||
|
|
||||||
function()
|
function()
|
||||||
require('nvim-ts-autotag').setup {}
|
require('nvim-ts-autotag').setup {}
|
||||||
|
120
lua/core/folding.lua
Normal file
120
lua/core/folding.lua
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
--- Stolen from: https://github.com/Wansmer/nvim-config/blob/main/lua/modules/foldtext.lua
|
||||||
|
--- modified for my use
|
||||||
|
---
|
||||||
|
---@module Foldtext
|
||||||
|
---Based on https://www.reddit.com/r/neovim/comments/16sqyjz/finally_we_can_have_highlighted_folds/
|
||||||
|
---Updated with vim.treesitter._fold.foldtext()
|
||||||
|
|
||||||
|
|
||||||
|
local function parse_line(linenr)
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
|
local line = vim.api.nvim_buf_get_lines(bufnr, linenr - 1, linenr, false)[1]
|
||||||
|
if not line then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||||
|
if not ok then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get(parser:lang(), "highlights")
|
||||||
|
if not query then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local tree = parser:parse({ linenr - 1, linenr })[1]
|
||||||
|
local result = {}
|
||||||
|
local line_pos = 0
|
||||||
|
|
||||||
|
for id, node, metadata in query:iter_captures(tree:root(), 0, linenr - 1, linenr) do
|
||||||
|
local name = query.captures[id]
|
||||||
|
local start_row, start_col, end_row, end_col = node:range()
|
||||||
|
|
||||||
|
local priority = tonumber(metadata.priority or vim.highlight.priorities.treesitter)
|
||||||
|
|
||||||
|
if start_row == linenr - 1 and end_row == linenr - 1 then
|
||||||
|
-- check for characters ignored by treesitter
|
||||||
|
if start_col > line_pos then
|
||||||
|
table.insert(result, {
|
||||||
|
line:sub(line_pos + 1, start_col),
|
||||||
|
{ { "Folded", priority } },
|
||||||
|
range = { line_pos, start_col },
|
||||||
|
})
|
||||||
|
end
|
||||||
|
line_pos = end_col
|
||||||
|
|
||||||
|
local text = line:sub(start_col + 1, end_col)
|
||||||
|
table.insert(result, { text, { { "@" .. name, priority } }, range = { start_col, end_col } })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
while i <= #result do
|
||||||
|
-- find first capture that is not in current range and apply highlights on the way
|
||||||
|
local j = i + 1
|
||||||
|
while j <= #result and result[j].range[1] >= result[i].range[1] and result[j].range[2] <= result[i].range[2] do
|
||||||
|
for k, v in ipairs(result[i][2]) do
|
||||||
|
if not vim.tbl_contains(result[j][2], v) then
|
||||||
|
table.insert(result[j][2], k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
j = j + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- remove the parent capture if it is split into children
|
||||||
|
if j > i + 1 then
|
||||||
|
table.remove(result, i)
|
||||||
|
else
|
||||||
|
-- highlights need to be sorted by priority, on equal prio, the deeper nested capture (earlier
|
||||||
|
-- in list) should be considered higher prio
|
||||||
|
if #result[i][2] > 1 then
|
||||||
|
table.sort(result[i][2], function(a, b)
|
||||||
|
return a[2] < b[2]
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
result[i][2] = vim.tbl_map(function(tbl)
|
||||||
|
return tbl[1]
|
||||||
|
end, result[i][2])
|
||||||
|
result[i] = { result[i][1], result[i][2] }
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
--- create a string of highlighted text for folds
|
||||||
|
---@return table|string
|
||||||
|
local function HighlightedFoldtext()
|
||||||
|
local result = parse_line(vim.v.foldstart)
|
||||||
|
if not result then
|
||||||
|
return vim.fn.foldtext()
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(result, {
|
||||||
|
" ... ",
|
||||||
|
"LspCodeLens",
|
||||||
|
})
|
||||||
|
|
||||||
|
local result2 = parse_line(vim.v.foldend)
|
||||||
|
if result2 then
|
||||||
|
local first = result2[1]
|
||||||
|
result2[1] = { vim.trim(first[1]), first[2] }
|
||||||
|
for _, item in ipairs(result2) do
|
||||||
|
table.insert(result, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(result, {
|
||||||
|
" "..(vim.v.foldend - vim.v.foldstart + 1).." Lines Folded ",
|
||||||
|
"LspCodeLens",
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
return HighlightedFoldtext
|
@ -1,90 +1,115 @@
|
|||||||
local misc = require('core.misc')
|
local misc = require('core.misc')
|
||||||
local map = misc.map
|
local map, include = misc.map, misc.include
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local function on_list(options)
|
||||||
|
vim.fn.setqflist({}, 'r', options)
|
||||||
|
if #options.items > 1 then
|
||||||
|
vim.cmd.copen()
|
||||||
|
end
|
||||||
|
vim.cmd("cc! 1")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _w(func)
|
||||||
|
return function()
|
||||||
|
func({
|
||||||
|
border = "solid",
|
||||||
|
max_width = math.floor(vim.o.columns * 0.7),
|
||||||
|
}, { on_list = on_list })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- setup basic options on lsp attach
|
||||||
|
---@param bufnr number buffer number
|
||||||
|
local function attach(bufnr)
|
||||||
|
local opts = { buffer = bufnr, nowait = true }
|
||||||
|
|
||||||
|
-- LSP actions
|
||||||
|
map('n', 'K', _w(vim.lsp.buf.hover), opts)
|
||||||
|
map('n', 'gd', _w(vim.lsp.buf.definition), opts)
|
||||||
|
map('n', 'gD', _w(vim.lsp.buf.declaration), opts)
|
||||||
|
map('n', 'gi', _w(vim.lsp.buf.implementation), opts)
|
||||||
|
map('n', 'gy', _w(vim.lsp.buf.type_definition), opts)
|
||||||
|
map('n', 'gr', _w(vim.lsp.buf.references), opts)
|
||||||
|
map('n', '<S-Tab>', _w(vim.lsp.buf.signature_help), opts)
|
||||||
|
map('n', { '<leader>r', '<F2>' }, _w(vim.lsp.buf.rename), opts)
|
||||||
|
map('n', 'gA', _w(vim.lsp.buf.code_action), {
|
||||||
|
buffer = bufnr,
|
||||||
|
desc = 'check code actions',
|
||||||
|
})
|
||||||
|
map('n', '<F4>', _w(vim.lsp.buf.code_action), {
|
||||||
|
buffer = bufnr,
|
||||||
|
desc = 'check code actions'
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
map('n', '[d', function()
|
||||||
|
if not vim.fn.has("nvim-0.11") then
|
||||||
|
vim.diagnostic.goto_prev()
|
||||||
|
else
|
||||||
|
vim.diagnostic.jump({ count = -1 })
|
||||||
|
end
|
||||||
|
end, opts)
|
||||||
|
map('n', ']d', function()
|
||||||
|
if not vim.fn.has("nvim-0.11") then
|
||||||
|
vim.diagnostic.goto_next()
|
||||||
|
else
|
||||||
|
vim.diagnostic.jump({ count = 1 })
|
||||||
|
end
|
||||||
|
end, opts)
|
||||||
|
-- map('n', 'qD', vim.diagnostic.setqflist, opts)
|
||||||
|
end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.diagnostic.config {
|
vim.diagnostic.config {
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
virtual_lines = {
|
virtual_lines = {
|
||||||
only_current_line = true,
|
only_current_line = true,
|
||||||
},
|
},
|
||||||
signs = true,
|
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
underline = true,
|
underline = true,
|
||||||
severity_sort = true
|
severity_sort = true,
|
||||||
}
|
signs = {
|
||||||
|
text = {
|
||||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
[vim.diagnostic.severity.ERROR] = "x",
|
||||||
vim.lsp.handlers.hover, { border = 'solid' })
|
[vim.diagnostic.severity.WARN] = "!",
|
||||||
|
[vim.diagnostic.severity.INFO] = "i",
|
||||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
[vim.diagnostic.severity.HINT] = "h",
|
||||||
vim.lsp.handlers.signature_help, { border = 'solid' })
|
|
||||||
|
|
||||||
for _, v in pairs({
|
|
||||||
{ "DiagnosticSignError", "x" },
|
|
||||||
{ "DiagnosticSignWarn", "!" },
|
|
||||||
{ "DiagnosticSignInfo", "i" },
|
|
||||||
{ "DiagnosticSignHint", "h" }
|
|
||||||
}) do
|
|
||||||
vim.fn.sign_define(v[1], { text = v[2], texthl = v[1] })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- generate client capabilities for lsp servers
|
|
||||||
---@return table capabilities
|
|
||||||
function M.capabilities()
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities.textDocument.completion.completionItem = {
|
|
||||||
snippetSupport = true,
|
|
||||||
preselectSupport = true,
|
|
||||||
insertReplaceSupport = true,
|
|
||||||
labelDetailsSupport = true,
|
|
||||||
deprecatedSupport = true,
|
|
||||||
commitCharactersSupport = true,
|
|
||||||
tagSupport = {
|
|
||||||
valueSet = { 1 }
|
|
||||||
},
|
|
||||||
resolveSupport = {
|
|
||||||
properties = {
|
|
||||||
"documentation",
|
|
||||||
"detail",
|
|
||||||
"additionalTextEdits"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return capabilities
|
if not vim.fn.has("nvim-0.11") then
|
||||||
|
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
|
||||||
|
|
||||||
|
-- set default capabilities
|
||||||
|
include('lspconfig.util').default_config.capabilities = M.capabilities
|
||||||
|
|
||||||
|
-- run whenever a client attaches
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
callback = function(event)
|
||||||
|
-- map keybinds
|
||||||
|
attach(event.buf)
|
||||||
|
end
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--- setup basic options on lsp attach
|
--- capabilities that are to be used in lsp servers, for those setup through
|
||||||
---@param client number client number
|
--- lspconfig, this is already set as the default. Incase there is a server
|
||||||
---@param bufnr number buffer number
|
--- not setup through lspconfig this function may be called to receive the
|
||||||
function M.attach(client, bufnr)
|
--- proper capabilities data.
|
||||||
local opts = { buffer = bufnr }
|
M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
-- LSP actions
|
|
||||||
map('n', 'K', vim.lsp.buf.hover, opts)
|
|
||||||
map('n', 'gd', vim.lsp.buf.definition, opts)
|
|
||||||
map('n', 'gD', vim.lsp.buf.declaration)
|
|
||||||
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>r', 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
|
--- add capabilities to the default capabilities string
|
||||||
map('n', '[d', vim.diagnostic.goto_prev, opts)
|
---@param new_capabilities lsp.ClientCapabilities
|
||||||
map('n', ']d', vim.diagnostic.goto_next, opts)
|
function M.add_capabilities(new_capabilities)
|
||||||
-- map('n', 'qD', vim.diagnostic.setqflist, opts)
|
vim.tbl_deep_extend('force', M.capabilities, new_capabilities)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -29,10 +29,19 @@ end
|
|||||||
--- set colorscheme
|
--- set colorscheme
|
||||||
---@param name string name of colorscheme
|
---@param name string name of colorscheme
|
||||||
function M.colorscheme(name)
|
function M.colorscheme(name)
|
||||||
vim.cmd.colorscheme(name)
|
-- only set the colorscheme if it exists
|
||||||
|
for _, v in pairs(vim.fn.getcompletion('', 'color')) do
|
||||||
|
if v == name then
|
||||||
|
vim.cmd("colorscheme "..name)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- override with any addons
|
||||||
for _, v in pairs(vim.fn.getcompletion('', 'color')) do
|
for _, v in pairs(vim.fn.getcompletion('', 'color')) do
|
||||||
if v == name..'.ext' then
|
if v == name..'.ext' then
|
||||||
vim.cmd.colorscheme(name..'.ext')
|
vim.cmd("colorscheme"..name..'.ext')
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -41,12 +50,24 @@ end
|
|||||||
---@param mode string|table mode for the keymap
|
---@param mode string|table mode for the keymap
|
||||||
---@param bind string|table keymap
|
---@param bind string|table keymap
|
||||||
---@param cmd function|string command to run
|
---@param cmd function|string command to run
|
||||||
---@param opts table? keymap options
|
---@param opts vim.keymap.set.Opts? keymap options
|
||||||
function M.map(mode, bind, cmd, opts)
|
function M.map(mode, bind, cmd, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
opts['noremap'] = true
|
opts['noremap'] = true
|
||||||
opts['silent'] = true
|
opts['silent'] = true
|
||||||
|
|
||||||
|
-- attempt to autogenerate a basic description
|
||||||
|
if not opts['desc'] then
|
||||||
|
if type(cmd) == "string" then
|
||||||
|
opts['desc'] = cmd:gsub("<%a+>", "")
|
||||||
|
elseif type(cmd) == "function" then
|
||||||
|
-- TODO: find a way to generate a better name
|
||||||
|
local file_name = vim.fn.fnamemodify(debug.getinfo(cmd, "S").short_src, ":t")
|
||||||
|
opts['desc'] = "origin@"..file_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- define the keybinds
|
||||||
if type(bind) == 'table' then
|
if type(bind) == 'table' then
|
||||||
for i in pairs(bind) do
|
for i in pairs(bind) do
|
||||||
vim.keymap.set(mode, bind[i], cmd, opts)
|
vim.keymap.set(mode, bind[i], cmd, opts)
|
||||||
@ -69,7 +90,7 @@ end
|
|||||||
|
|
||||||
--- extend vim.api.nvim_create_autocmd
|
--- extend vim.api.nvim_create_autocmd
|
||||||
---@param event string|table event or events
|
---@param event string|table event or events
|
||||||
---@param opts table options
|
---@param opts vim.api.keyset.create_autocmd options
|
||||||
function M.auto(event, opts)
|
function M.auto(event, opts)
|
||||||
vim.api.nvim_create_autocmd(event, opts)
|
vim.api.nvim_create_autocmd(event, opts)
|
||||||
end
|
end
|
||||||
@ -161,24 +182,29 @@ function M.timeout_highlight(opts)
|
|||||||
|
|
||||||
-- timer code was happily stolen from neovim/runtime/lua/vim/highlight.lua :)
|
-- timer code was happily stolen from neovim/runtime/lua/vim/highlight.lua :)
|
||||||
local timer, timer_cancel
|
local timer, timer_cancel
|
||||||
|
if not vim.fn.has("nvim-0.11") then
|
||||||
if timer then
|
if timer then
|
||||||
timer:close()
|
timer:close()
|
||||||
assert(timer_cancel)
|
assert(timer_cancel)
|
||||||
timer_cancel()
|
timer_cancel()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set the highlight
|
-- set the highlight
|
||||||
vim.highlight.range(0, namespaceid, opts.hl, opts.range[1], opts.range[2], {})
|
vim.highlight.range(0, namespaceid, opts.hl, opts.range[1], opts.range[2], {
|
||||||
|
opts.timeout,
|
||||||
|
})
|
||||||
|
|
||||||
timer_cancel = function()
|
if not vim.fn.has("nvim-0.11") then
|
||||||
timer = nil
|
timer_cancel = function()
|
||||||
timer_cancel = nil
|
timer = nil
|
||||||
pcall(vim.api.nvim_buf_clear_namespace, 0, namespaceid, 0, -1)
|
timer_cancel = nil
|
||||||
pcall(vim.api.nvim_win_remove_ns, 0, namespaceid)
|
pcall(vim.api.nvim_buf_clear_namespace, 0, namespaceid, 0, -1)
|
||||||
|
pcall(vim.api.nvim_win_remove_ns, 0, namespaceid)
|
||||||
|
end
|
||||||
|
|
||||||
|
timer = vim.defer_fn(timer_cancel, opts.timeout)
|
||||||
end
|
end
|
||||||
|
|
||||||
timer = vim.defer_fn(timer_cancel, opts.timeout)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Reference in New Issue
Block a user