summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-01-24 13:56:11 -0600
committerSquibid <me@zacharyscheiman.com>2025-01-24 13:56:11 -0600
commit8eaa615596be321a3be12378c5e7d65cc7e482b6 (patch)
tree53fe601048ea302962420de4feff465e4c7d9317
parenta0ebc39b59a98a69fbb6abf150f86dc4e19987a3 (diff)
downloadnvim-master.tar.gz
nvim-master.tar.bz2
nvim-master.zip
kitchen sinkHEADmaster
-rw-r--r--extras/JavaVersion.java6
-rw-r--r--init.lua3
-rw-r--r--lua/conf/binds.lua18
-rw-r--r--lua/conf/opts.lua2
-rw-r--r--lua/conf/plugins/biscuit.lua1
-rw-r--r--lua/conf/plugins/dressing.lua4
-rw-r--r--lua/conf/plugins/fidget.lua2
-rw-r--r--lua/conf/plugins/glance.lua44
-rw-r--r--lua/conf/plugins/incline.lua12
-rw-r--r--lua/conf/plugins/jdtls.lua143
-rw-r--r--lua/conf/plugins/leetcode.lua17
-rw-r--r--lua/conf/plugins/lsp_lines.lua13
-rw-r--r--lua/conf/plugins/lspconfig.lua18
-rw-r--r--lua/conf/plugins/luasnip.lua5
-rw-r--r--lua/conf/plugins/mason-lspconfig.lua273
-rw-r--r--lua/conf/plugins/mellow.lua8
-rw-r--r--lua/conf/plugins/smear.lua13
-rw-r--r--lua/conf/plugins/telescope.lua15
-rw-r--r--lua/conf/plugins/treesitter-context.lua40
-rw-r--r--lua/conf/plugins/treesitter.lua12
-rw-r--r--lua/core/lsp/functions.lua90
-rw-r--r--lua/core/snippets/functions.lua2
-rw-r--r--lua/lsps/clangd.lua31
-rw-r--r--lua/snippets/c.lua14
-rw-r--r--lua/snippets/tex.lua70
25 files changed, 444 insertions, 412 deletions
diff --git a/extras/JavaVersion.java b/extras/JavaVersion.java
index 5e4a4c7..756d113 100644
--- a/extras/JavaVersion.java
+++ b/extras/JavaVersion.java
@@ -4,10 +4,6 @@
*/
public final class JavaVersion {
public static void main(String[] args) {
- String p = System.getProperty("java.version");
- if (p != null)
- System.out.println(p);
- else
- System.exit(1);
+ System.out.println(System.getProperty("java.version"));
}
}
diff --git a/init.lua b/init.lua
index c6bf0af..042713b 100644
--- a/init.lua
+++ b/init.lua
@@ -20,7 +20,8 @@ misc.include('conf.context') -- setup context menu
-- load plugins
require('dep') {
{ 'squibid/dep',
- url = 'https://git.squi.bid/dep'
+ url = 'https://git.squi.bid/dep',
+ branch = "dev"
},
load = function()
diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua
index 2f5673a..1426ac3 100644
--- a/lua/conf/binds.lua
+++ b/lua/conf/binds.lua
@@ -14,8 +14,8 @@ map('v', '<S-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selected text down.' })
map('n', '<S-j>', 'mzJ`z<cmd>delm z<CR>') -- when combining lines
map('n', 'n', 'nzzzv') -- when searching
map('n', 'N', 'Nzzzv')
-map('n', '<C-d>', '<C-d>zz') -- half page jumping
-map('n', '<C-u>', '<C-u>zz')
+map('n', '<C-d>', '<C-d>zzzv') -- half page jumping
+map('n', '<C-u>', '<C-u>zzzv')
map('n', '<leader>x', function() -- execute order 111
local fn = vim.fn.expand("%:p")
@@ -33,12 +33,6 @@ map('n', '<leader>x', function() -- execute order 111
end
end, { desc = 'toggle executable flag of the file' })
--- tabs
-map('n', '[]', '<cmd>tabnew<CR>')
-map('n', '][', '<cmd>tabc<CR>')
-map('n', '[[', '<cmd>tabp<CR>')
-map('n', ']]', '<cmd>tabn<CR>')
-
-- good spell suggestion ui
-- (stolen from https://github.com/neovim/neovim/pull/25833)
vim.keymap.set('n', 'z=', function()
@@ -56,3 +50,11 @@ vim.keymap.set('n', 'z=', function()
local prompt = 'Change '..vim.inspect(cword)..' to:'
vim.ui.select(vim.fn.spellsuggest(cword, vim.o.lines), { prompt = prompt }, spell_on_choice)
end, { desc = 'Shows spelling suggestions' })
+
+-- quickfix
+map('n', '<M-j>', '<cmd>cnext<CR>zz')
+map('n', '<M-k>', '<cmd>cprev<CR>zz')
+map('n', '<M-c>', '<cmd>cclose<CR>')
+
+-- open up Ex
+map('n', '<leader>c', '<cmd>Ex<CR>')
diff --git a/lua/conf/opts.lua b/lua/conf/opts.lua
index 91c8055..db75358 100644
--- a/lua/conf/opts.lua
+++ b/lua/conf/opts.lua
@@ -3,6 +3,8 @@ if vim.fn.has("termguicolors") then
vim.opt.termguicolors = true
end
+vim.opt.laststatus = 3
+
-- buffer
vim.opt.scrolloff = 5
vim.opt.wrap = true -- wraping lines
diff --git a/lua/conf/plugins/biscuit.lua b/lua/conf/plugins/biscuit.lua
deleted file mode 100644
index d5a1067..0000000
--- a/lua/conf/plugins/biscuit.lua
+++ /dev/null
@@ -1 +0,0 @@
-return { 'Biscuit-Theme/nvim' }
diff --git a/lua/conf/plugins/dressing.lua b/lua/conf/plugins/dressing.lua
index 64f9723..36622a6 100644
--- a/lua/conf/plugins/dressing.lua
+++ b/lua/conf/plugins/dressing.lua
@@ -12,9 +12,7 @@ return { 'stevearc/dressing.nvim',
function()
require('dressing').setup {
input = {
- title_pos = "center",
- border = 'solid',
- relative = "win"
+ enabled = false
}
}
end
diff --git a/lua/conf/plugins/fidget.lua b/lua/conf/plugins/fidget.lua
index 044f4ec..667c905 100644
--- a/lua/conf/plugins/fidget.lua
+++ b/lua/conf/plugins/fidget.lua
@@ -1,6 +1,6 @@
return { 'j-hui/fidget.nvim',
disable = vim.version().minor < 9,
- branch = "v1.4.5",
+ branch = "v1.5.0",
function()
local notification_defaults = require("fidget.notification").default_config
notification_defaults["icon"] = ""
diff --git a/lua/conf/plugins/glance.lua b/lua/conf/plugins/glance.lua
deleted file mode 100644
index c5a4d41..0000000
--- a/lua/conf/plugins/glance.lua
+++ /dev/null
@@ -1,44 +0,0 @@
-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
-}
diff --git a/lua/conf/plugins/incline.lua b/lua/conf/plugins/incline.lua
deleted file mode 100644
index 3dab96d..0000000
--- a/lua/conf/plugins/incline.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-return { 'b0o/incline.nvim',
- function()
- vim.cmd.set('laststatus=3')
-
- require('incline').setup {
- hide = {
- focused_win = true,
- cursorline = true
- }
- }
- end
-}
diff --git a/lua/conf/plugins/jdtls.lua b/lua/conf/plugins/jdtls.lua
index 6bbff1c..c847e5a 100644
--- a/lua/conf/plugins/jdtls.lua
+++ b/lua/conf/plugins/jdtls.lua
@@ -1,4 +1,145 @@
+local misc = require('core.misc')
+local lsp = require('core.lsp.functions')
+local map, auto = misc.map, misc.auto
+
return { 'mfussenegger/nvim-jdtls',
disable = vim.version().minor < 6,
- requires = 'mfussenegger/nvim-dap'
+ requires = 'mfussenegger/nvim-dap',
+ function()
+ auto("FileType", {
+ pattern = "java",
+ callback = function()
+ 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',
+ 'build.xml'
+ }, { upward = true })[1]),
+
+ -- don't print out status messages
+ handlers = {
+ ['language/status'] = function() end
+ },
+
+ capabilities = lsp.capabilities(),
+ 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', 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,
+ }
+
+ ---@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
+ })
+ end
+ })
+ end
}
diff --git a/lua/conf/plugins/leetcode.lua b/lua/conf/plugins/leetcode.lua
new file mode 100644
index 0000000..bda7c08
--- /dev/null
+++ b/lua/conf/plugins/leetcode.lua
@@ -0,0 +1,17 @@
+return { 'kawre/leetcode.nvim',
+ requires = {
+ 'nvim-lua/plenary.nvim',
+ 'nvim-telescope/telescope.nvim',
+ 'MunifTanjim/nui.nvim',
+ 'nvim-treesitter/nvim-treesitter'
+ },
+ config = function()
+ -- because we're using treesitter make sure to install the html parser
+ vim.cmd.TSUpdate("html")
+ end,
+ function()
+ require('leetcode').setup {
+ lang = "java"
+ }
+ end
+}
diff --git a/lua/conf/plugins/lsp_lines.lua b/lua/conf/plugins/lsp_lines.lua
index 5f8e05d..e28aec8 100644
--- a/lua/conf/plugins/lsp_lines.lua
+++ b/lua/conf/plugins/lsp_lines.lua
@@ -1,12 +1,3 @@
-return { 'whynothugo/lsp_lines.nvim',
- url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim',
- requires = 'neovim/nvim-lspconfig',
- function()
- vim.diagnostic.config {
- virtual_lines = {
- highlight_whole_line = false,
- only_current_line = true
- }
- }
- end
+return { 'whynothugo/lsp_lines',
+ url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim'
}
diff --git a/lua/conf/plugins/lspconfig.lua b/lua/conf/plugins/lspconfig.lua
deleted file mode 100644
index 3dce638..0000000
--- a/lua/conf/plugins/lspconfig.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-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
-}
diff --git a/lua/conf/plugins/luasnip.lua b/lua/conf/plugins/luasnip.lua
index 055fb02..d881a57 100644
--- a/lua/conf/plugins/luasnip.lua
+++ b/lua/conf/plugins/luasnip.lua
@@ -13,6 +13,7 @@ return { 'L3MON4D3/LuaSnip',
luasnip.config.set_config {
history = true, -- return back into snippet
+ enable_autosnippets = true,
-- update on text insert and cursor hold
updateevents = { "TextChanged", "TextChangedI", "CursorHold" },
@@ -26,8 +27,8 @@ return { 'L3MON4D3/LuaSnip',
active = {
virt_text = {{ "●", "@constant" }}
}
- },
- },
+ }
+ }
}
map({"i", "s"}, "<c-a>", function()
diff --git a/lua/conf/plugins/mason-lspconfig.lua b/lua/conf/plugins/mason-lspconfig.lua
index e746d5b..65c5693 100644
--- a/lua/conf/plugins/mason-lspconfig.lua
+++ b/lua/conf/plugins/mason-lspconfig.lua
@@ -1,74 +1,20 @@
local misc = require('core.misc')
+local lsp = require('core.lsp.functions')
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'
+ { 'neovim/nvim-lspconfig',
+ disable = vim.version().minor < 8,
+ function()
+ lsp.setup()
+ end
+ }
},
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 = {
@@ -86,8 +32,8 @@ return { 'williamboman/mason-lspconfig.nvim',
require('mason-lspconfig').setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
- on_attach = lsp_attach,
- capabilities = capabilities
+ on_attach = lsp.lsp_attach,
+ capabilities = lsp.capabilities()
}
end,
@@ -101,7 +47,8 @@ return { 'williamboman/mason-lspconfig.nvim',
-- FIXME: luals 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,
+ on_attach = lsp.attach,
+ capabilities = lsp.capabilities(),
settings = {
Lua = {
diagnostics = {
@@ -141,13 +88,13 @@ return { 'williamboman/mason-lspconfig.nvim',
["clangd"] = function(server_name)
require('lspconfig')[server_name].setup {
on_attach = function(client, bufnr)
- lsp_attach(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,
+ capabilities = lsp.capabilities(),
cmd = {
"clangd",
@@ -168,197 +115,9 @@ return { 'williamboman/mason-lspconfig.nvim',
}
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", "build.xml" })
-
- -- start it up
- jdtls.start_or_attach(config)
- end
- end
- })
- end
+ -- disable it, we start this using nvim-jdtls
+ ["jdtls"] = function(_) end
}
+
end
}
diff --git a/lua/conf/plugins/mellow.lua b/lua/conf/plugins/mellow.lua
index af805ed..11103ae 100644
--- a/lua/conf/plugins/mellow.lua
+++ b/lua/conf/plugins/mellow.lua
@@ -1,4 +1,5 @@
return { 'mellow-theme/mellow.nvim',
+ disable = vim.version().minor < 8,
requires = 'nvim-treesitter/nvim-treesitter',
function()
vim.g.mellow_variant = "dark"
@@ -29,7 +30,12 @@ return { 'mellow-theme/mellow.nvim',
["@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" }
+ ["@neorg.headings.6.icon"] = { link = "@neorg.headings.6.title" },
+
+ -- make blink actually look nice
+ ["BlinkCmpMenu"] = { bg = c.bg_dark },
+ ["BlinkCmpMenuBorder"] = { link = "BlinkCmpMenu" },
+ ["BlinkCmpMenuSelection"] = { bg = c.gray02 }
}
end
}
diff --git a/lua/conf/plugins/smear.lua b/lua/conf/plugins/smear.lua
new file mode 100644
index 0000000..4e0e051
--- /dev/null
+++ b/lua/conf/plugins/smear.lua
@@ -0,0 +1,13 @@
+-- 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
+}
diff --git a/lua/conf/plugins/telescope.lua b/lua/conf/plugins/telescope.lua
index 68a7c23..597fbe3 100644
--- a/lua/conf/plugins/telescope.lua
+++ b/lua/conf/plugins/telescope.lua
@@ -76,6 +76,21 @@ return { 'nvim-telescope/telescope.nvim',
map('n', '<leader>b', telebuilt.current_buffer_fuzzy_find, {
desc = 'Find string in current buffer.',
})
+ map('n', '<leader>i', telebuilt.help_tags, {
+ desc = 'Fuzzy find over help tags.',
+ })
+
+ -- find over specific directories
+ map('n', '<leader>tc', function()
+ require('telescope.builtin').find_files {
+ cwd = vim.fn.stdpath("config")
+ }
+ end, { desc = "Fuzzy find over files in my config" })
+ map('n', '<leader>tp', function()
+ require('telescope.builtin').find_files {
+ cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "site/pack/deps/opt")
+ }
+ end, { desc = "Fuzzy find over files in my plugin directory" })
-- enable previewing in the default colorscheme switcher
telebuilt.colorscheme = function()
diff --git a/lua/conf/plugins/treesitter-context.lua b/lua/conf/plugins/treesitter-context.lua
deleted file mode 100644
index 3306e6b..0000000
--- a/lua/conf/plugins/treesitter-context.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-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
-}
diff --git a/lua/conf/plugins/treesitter.lua b/lua/conf/plugins/treesitter.lua
index a81e295..4f010d9 100644
--- a/lua/conf/plugins/treesitter.lua
+++ b/lua/conf/plugins/treesitter.lua
@@ -8,7 +8,7 @@ table.contains = function(self, string)
end
return { 'nvim-treesitter/nvim-treesitter',
- disable = vim.version.lt(vim.version(), { 0, 9, 2 }),
+ disable = vim.version().minor < 10,
config = function()
vim.cmd.TSUpdate()
end,
@@ -24,11 +24,11 @@ return { 'nvim-treesitter/nvim-treesitter',
indent = {
enable = true,
- disable = function(lang, buf)
+ disable = function(lang, _)
-- disable indenting in php (it's more broken with than without)
- return table.contains({
+ return table.contains(({
"php"
- }, lang)
+ }), lang)
end
},
@@ -40,9 +40,9 @@ return { 'nvim-treesitter/nvim-treesitter',
disable = function(lang, buf)
-- disable in some files where vim's builtin highlighting is better
- if table.contains({
+ if table.contains(({
"diff", "tex"
- }, lang) then
+ }), lang) then
return true
end
diff --git a/lua/core/lsp/functions.lua b/lua/core/lsp/functions.lua
new file mode 100644
index 0000000..ab47ccc
--- /dev/null
+++ b/lua/core/lsp/functions.lua
@@ -0,0 +1,90 @@
+local misc = require('core.misc')
+local map = misc.map
+
+local M = {}
+
+function M.setup()
+ vim.diagnostic.config {
+ virtual_text = false,
+ virtual_lines = {
+ only_current_line = true,
+ },
+ 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' })
+
+ 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
+end
+
+--- setup basic options on lsp attach
+---@param client number client number
+---@param bufnr number buffer number
+function M.attach(client, bufnr)
+ 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', 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
+ map('n', '[d', vim.diagnostic.goto_prev, opts)
+ map('n', ']d', vim.diagnostic.goto_next, opts)
+ -- map('n', 'qD', vim.diagnostic.setqflist, opts)
+end
+
+return M
diff --git a/lua/core/snippets/functions.lua b/lua/core/snippets/functions.lua
index 56b24b6..24fc8a6 100644
--- a/lua/core/snippets/functions.lua
+++ b/lua/core/snippets/functions.lua
@@ -1,3 +1,3 @@
-function file_name(args, parent, user_args)
+function file_name(_, _, _)
return vim.fn.expand("%:t:r")
end
diff --git a/lua/lsps/clangd.lua b/lua/lsps/clangd.lua
new file mode 100644
index 0000000..05ebfb7
--- /dev/null
+++ b/lua/lsps/clangd.lua
@@ -0,0 +1,31 @@
+local map = require('core.misc').map
+
+return function(server_name, attach, capabilities)
+ require('lspconfig')[server_name].setup {
+ on_attach = function(client, bufnr)
+ 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
diff --git a/lua/snippets/c.lua b/lua/snippets/c.lua
index 65463dc..be0a683 100644
--- a/lua/snippets/c.lua
+++ b/lua/snippets/c.lua
@@ -9,8 +9,21 @@ local function c_func(func)
local q = vim.treesitter.query.parse("c", "(function_definition) @f")
local matches = q:iter_matches(tree, 0)
+ vim.treesitter.query.parse("c", "(identifier) @i")
+ local m = q:iter_matches(matches, 0)
+ print(vim.treesitter.get_node_text(m:child(), 0))
+
+ if true then
+ return
+ end
+
for _, match in matches do
for _, node in pairs(match) do
+ if not node or not node:child(1) or not node:child(1):child() then
+ -- print(vim.treesitter.get_node_text(node:child(1):child(), 0))
+ goto continue
+ end
+
if vim.treesitter.get_node_text(node:child(1):child(), 0) == func then
local def = ""
for i = 0, node:child_count() - 2 do
@@ -22,6 +35,7 @@ local function c_func(func)
-- Print the function name using node text
return def:gsub("\n", "")
end
+ ::continue::
end
end
diff --git a/lua/snippets/tex.lua b/lua/snippets/tex.lua
new file mode 100644
index 0000000..0e87437
--- /dev/null
+++ b/lua/snippets/tex.lua
@@ -0,0 +1,70 @@
+require('core.snippets.shorthands')
+require('core.snippets.functions')
+
+return {
+ -- document snippet
+ s("doc",
+ fmta(
+ [[
+ \documentclass{article}
+ \title{<>}
+ \author{<>}
+ \begin{document}
+ \maketitle
+ <>
+ \end{document}
+ ]],
+ {
+ c(1, {
+ sn(nil, { f(file_name, {}), i(1) }),
+ i(1, "my title")
+ }),
+ i(2, "my name"),
+ i(0)
+ }
+ )
+ ),
+
+ s({ trig = ";begin", snippetType = "autosnippet" },
+ fmta(
+ [[
+ \begin{<>}
+ <>
+ \end{<>}
+ ]],
+ {
+ i(1),
+ i(0),
+ rep(1)
+ }
+ )
+ ),
+
+ s({ trig = ";href", snippetType = "autosnippet" },
+ fmta(
+ [[\href{<>}{<>}]],
+ {
+ i(1, "url"),
+ i(2, "display name"),
+ }
+ )
+ ),
+
+ postfix(".b", {
+ f(function(_, parent)
+ return [[\textbf{]]..parent.snippet.env.POSTFIX_MATCH.."}"
+ end)
+ }),
+
+ postfix(".i", {
+ f(function(_, parent)
+ return [[\textit{]]..parent.snippet.env.POSTFIX_MATCH.."}"
+ end)
+ }),
+
+ postfix(".ul", {
+ f(function(_, parent)
+ return [[\underline{]]..parent.snippet.env.POSTFIX_MATCH.."}"
+ end)
+ })
+}