1
0
Fork 0

finish new lsp keybind setup for nvim

This commit is contained in:
Luca Bilke 2024-01-25 00:10:11 +01:00
parent 484f0e9715
commit 9c3078a4bc
26 changed files with 460 additions and 190 deletions

View file

@ -1,4 +1,4 @@
vim.loader.enable()
-- vim.loader.enable()
require('config.options')
require('lazy-init')
require('config.autocmds')

View file

@ -1,37 +1,41 @@
local icons = require("config.icons")
local f = require("funcs")
local icons = require("config.icons")
local maps = f.empty_map_table()
local sections = {
p = { desc = icons.ui.Package .. " Packages" },
b = { desc = icons.ui.Tab .. " Buffers" },
bs = { desc = icons.ui.Tab .. " Sort Buffers" },
d = { desc = icons.ui.Debug .. " Debugger" },
g = { desc = icons.misc.Git .. " Git" },
f = { desc = icons.ui.Search .. " Find" },
l = { desc = icons.ui.Note .. " LSP" },
u = { desc = icons.ui.Gear .. " Utility" },
t = { desc = icons.ui.Terminal .. " Terminal" },
p = { desc = " " .. icons.ui.Package .. " Packages" },
b = { desc = " " .. icons.ui.Tab .. " Buffers" },
bs = { desc = " " .. icons.ui.Tab .. " Sort Buffers" },
d = { desc = " " .. icons.ui.Debug .. " Debugger" },
g = { desc = " " .. icons.misc.Git .. " Git" },
f = { desc = " " .. icons.ui.Search .. " Find" },
l = { desc = " " .. icons.ui.Note .. " LSP" },
m = { desc = " " .. icons.ui.Gear .. " Misc" },
t = { desc = " " .. icons.ui.Terminal .. " Terminal" },
}
-- Standard --
maps.n["j"] = { "v:count == 0 ? 'gj' : 'j'", expr = true, desc = "Move cursor down" }
maps.n["k"] = { "v:count == 0 ? 'gk' : 'k'", expr = true, desc = "Move cursor up" }
maps.n["<Leader>w"] = { "<Cmd>w<CR>", desc = "Write buffer" }
maps.n["<Leader>q"] = { "<Cmd>conf q<CR>", desc = "Quit" }
maps.n["<Leader>Q"] = { "<Cmd>conf qa<CR>", desc = "Quit all" }
maps.n["<Leader>c"] = { "<Cmd>conf q<CR>", desc = "Quit" }
maps.n["<Leader>C"] = { "<Cmd>conf qa<CR>", desc = "Quit all" }
maps.n["<Leader>n"] = { "<Cmd>ene<CR>", desc = "New buffer" }
maps.n["<Leader>h"] = { "<Cmd>noh<CR>", desc = "Clear highlight" }
maps.n["<C-s>"] = { "<cmd>w!<cr>", desc = "Force write buffer" }
maps.n["<C-q>"] = { "<cmd>qa!<cr>", desc = "Force quit all" }
maps.n["|"] = { "<cmd>vsplit<cr>", desc = "Vertical split" }
maps.n["\\"] = { "<cmd>split<cr>", desc = "Horizontal split" }
maps.v["<"] = { "<gv", desc = "Unindent line" }
maps.v[">"] = { ">gv", desc = "Indent line" }
maps.n["<Leader>c"] = { function() f.buf_close() end, desc = "Close buffer" }
maps.n["<Leader>C"] = { function() f.buf_close(0, true) end, desc = "Force close buffer" }
maps.n["<Leader>q"] = { f.buf_close, desc = "Close buffer" }
maps.n["<Leader>Q"] = { function() f.buf_close(0, true) end, desc = "Force close buffer" }
maps.n["<C-b>"] = { "<C-a>" }
maps.n["<C-f>"] = { "<Nop>" }
maps.i["<C-h>"] = { "<C-W>" }
-- TODO: Remove this when implemented in lsp_on_attach
maps.n["<Leader>lf"] = { vim.lsp.buf.format, desc = "Format" }
-- TODO: Add compiler script back (or don't tbh)
-- Window Navigation --
maps.n["<C-h>"] = { "<C-w>h", desc = "Move to left split" }
@ -113,12 +117,11 @@ if f.is_available("gitsigns.nvim") then
end
if f.is_available("lf.nvim") then
maps.n["<Leader>e"] = { "<Cmd>Lf<CR>", desc = "File Manager" }
maps.n["<Leader>e"] = { "<Cmd>Lf<CR>", desc = "File manager" }
end
if f.is_available("mason.nvim") then
maps.n["<Leader>pm"] = { "<cmd>Mason<cr>", desc = "Mason" }
maps.n["<Leader>pM"] = { "<cmd>MasonUpdateAll<cr>", desc = "Update Mason Packages" }
end
if f.is_available "aerial.nvim" then

View file

@ -0,0 +1,14 @@
return {
filter = function(client)
if require("funcs").is_available("none-ls.nvim") then
local n = require "null-ls"
local s = require "null-ls.sources"
local method = n.methods.FORMATTING
local available_formatters = s.get_available(vim.bo.filetype, method)
if #available_formatters > 0 then
return client.name == "null-ls"
end
end
return true
end
}

View file

@ -0,0 +1,13 @@
local conf = { handlers = {}, required = {} }
conf.handlers["intelephense"] = {
init_options = {
storagePath = os.getenv('XDG_CACHE_HOME') .. '/intelephense',
globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/license.txt',
}
}
conf.required = { "lua_ls", "bashls" }
return conf

View file

@ -1,4 +1,5 @@
local M = {}
local icons = require("config.icons")
function M.set_title()
local title = " %t"
@ -14,48 +15,23 @@ function M.set_title()
vim.opt.titlestring = title
end
function M.format_filter(client)
local filetype = vim.bo.filetype
local n = require "null-ls"
local s = require "null-ls.sources"
local method = n.methods.FORMATTING
local available_formatters = s.get_available(filetype, method)
if #available_formatters > 0 then
return client.name == "null-ls"
elseif client.supports_method "textDocument/formatting" then
return true
else
return false
end
end
function M.format(opts)
opts = opts or {}
opts.filter = opts.filter or M.format_filter
return vim.lsp.buf.format(opts)
end
-- Ripped from AstroNvim
function M.buf_close(bufnr, force)
if not bufnr or bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end
local buftype = vim.api.nvim_get_option_value("buftype", { buf = bufnr })
vim.cmd(("silent! %s %d"):format((force or buftype == "terminal") and "bdelete!" or "confirm bdelete", bufnr))
end
-- Ripped from AstroNvim
function M.is_available(plugin)
local lazy_config_avail, lazy_config = pcall(require, "lazy.core.config")
return lazy_config_avail and lazy_config.spec.plugins[plugin] ~= nil
end
-- Ripped from AstroNvim
-- TODO: Check this on 0.10.0 release
function M.empty_map_table()
local maps = {}
for _, mode in ipairs { "", "n", "v", "x", "s", "o", "!", "i", "l", "c", "t" } do
maps[mode] = {}
end
-- TODO: Check this on 0.10.0 release
if vim.fn.has "nvim-0.10.0" == 1 then
for _, abbr_mode in ipairs { "ia", "ca", "!a" } do
maps[abbr_mode] = {}
@ -64,7 +40,6 @@ function M.empty_map_table()
return maps
end
-- Ripped from AstroNvim and modified
function M.toggle_term_cmd(opts)
if not vim.g.user_terminals then
vim.g.user_terminals = {}
@ -84,7 +59,6 @@ function M.toggle_term_cmd(opts)
terms[opts.cmd][num]:toggle()
end
-- Ripped from AstroNvim and modified
-- TODO: test this
function M.file_worktree(file, worktrees)
worktrees = worktrees or vim.g.git_worktrees
@ -107,52 +81,75 @@ function M.file_worktree(file, worktrees)
end
end
-- Ripped from AstroNvim
function M.which_key_register()
if M.which_key_queue then
local wk_avail, wk = pcall(require, "which-key")
if wk_avail then
for mode, registration in pairs(M.which_key_queue) do
wk.register(registration, { mode = mode })
end
M.which_key_queue = nil
if M.which_key_queue then
local wk_avail, wk = pcall(require, "which-key")
if wk_avail then
for mode, registration in pairs(M.which_key_queue) do
wk.register(registration, { mode = mode })
end
M.which_key_queue = nil
end
end
end
end
-- Ripped from AstroNvim
function M.set_mappings(map_table, base)
base = base or {}
for mode, maps in pairs(map_table) do
for keymap, options in pairs(maps) do
if options then
local cmd = options
local keymap_opts = base
if type(options) == "table" then
cmd = options[1]
keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options)
keymap_opts[1] = nil
base = base or {}
for mode, maps in pairs(map_table) do
for keymap, options in pairs(maps) do
if options then
local cmd = options
local keymap_opts = base
if type(options) == "table" then
cmd = options[1]
keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options)
keymap_opts[1] = nil
end
if not cmd or keymap_opts.name then -- which-key mapping
if not keymap_opts.name then keymap_opts.name = keymap_opts.desc end
if not M.which_key_queue then M.which_key_queue = {} end
if not M.which_key_queue[mode] then M.which_key_queue[mode] = {} end
M.which_key_queue[mode][keymap] = keymap_opts
else -- not which-key mapping
vim.keymap.set(mode, keymap, cmd, keymap_opts)
end
end
end
if not cmd or keymap_opts.name then -- which-key mapping
if not keymap_opts.name then keymap_opts.name = keymap_opts.desc end
if not M.which_key_queue then M.which_key_queue = {} end
if not M.which_key_queue[mode] then M.which_key_queue[mode] = {} end
M.which_key_queue[mode][keymap] = keymap_opts
else -- not which-key mapping
vim.keymap.set(mode, keymap, cmd, keymap_opts)
end
end
end
end
if package.loaded["which-key"] then M.which_key_register() end
if package.loaded["which-key"] then M.which_key_register() end
end
local function del_buffer_autocmd(augroup, bufnr)
local cmds_found, cmds = pcall(vim.api.nvim_get_autocmds, { group = augroup, buffer = bufnr })
if cmds_found then vim.tbl_map(function(cmd) vim.api.nvim_del_autocmd(cmd.id) end, cmds) end
end
local function add_buffer_autocmd(augroup, bufnr, autocmds)
if not vim.tbl_islist(autocmds) then autocmds = { autocmds } end
local cmds_found, cmds = pcall(vim.api.nvim_get_autocmds, { group = augroup, buffer = bufnr })
if not cmds_found or vim.tbl_isempty(cmds) then
vim.api.nvim_create_augroup(augroup, { clear = false })
for _, autocmd in ipairs(autocmds) do
local events = autocmd.events
autocmd.events = nil
autocmd.group = augroup
autocmd.buffer = bufnr
vim.api.nvim_create_autocmd(events, autocmd)
end
end
end
local function has_capability(capability, filter)
for _, client in ipairs(vim.lsp.get_active_clients(filter)) do
if client.supports_method(capability) then return true end
end
return false
end
function M.lsp_on_attach(client, bufnr)
vim.fn.system("echo fuck >/home/luca/test")
local lsp_mappings = M.empty_map_table()
-- TODO: CONDITIONALLY GATE THIS
lsp_mappings.n["<leader>lf"] = { function() vim.lsp.buf.format() end, desc = "Format" }
lsp_mappings.n["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" }
lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" }
@ -165,25 +162,206 @@ function M.lsp_on_attach(client, bufnr)
}
end
if M.is_available "mason-lspconfig.nvim" then
if M.is_available("mason-lspconfig.nvim") then
lsp_mappings.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
end
if M.is_available "null-ls.nvim" then
if M.is_available("null-ls.nvim") then
lsp_mappings.n["<leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
end
if client.supports_method "textDocument/codeAction" then
if client.supports_method("textDocument/codeAction") then
lsp_mappings.n["<leader>la"] = {
function() vim.lsp.buf.code_action() end,
desc = "LSP code action",
desc = "Code action",
}
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
end
if client.supports_method("textDocument/codeLens") then
vim.lsp.codelens.refresh()
lsp_mappings.n["<leader>ll"] = {
function() vim.lsp.codelens.refresh() end,
desc = "Refresh CodeLens",
}
lsp_mappings.n["<leader>lL"] = {
function() vim.lsp.codelens.run() end,
desc = "Run CodeLens",
}
lsp_mappings.n["<leader>mL"] = {
function() vim.lsp.codelens.clear() end,
desc = "Toggle CodeLens"
}
end
if client.supports_method("textDocument/definition") then
lsp_mappings.n["gd"] = {
function() vim.lsp.buf.definition() end,
desc = "Go to definition",
}
end
if client.supports_method "textDocument/typeDefinition" then
lsp_mappings.n["gy"] = {
function() vim.lsp.buf.type_definition() end,
desc = "Go to type definition",
}
end
if client.supports_method("textDocument/declaration") then
lsp_mappings.n["gD"] = {
function() vim.lsp.buf.declaration() end,
desc = "Go to declaration",
}
end
if client.supports_method("textDocument/implementation") then
lsp_mappings.n["gI"] = {
function() vim.lsp.buf.implementation() end,
desc = "List implementations",
}
end
if client.supports_method("textDocument/references") then
lsp_mappings.n["gr"] = {
function() vim.lsp.buf.references() end,
desc = "List references",
}
end
if client.supports_method "workspace/symbol" then
lsp_mappings.n["<leader>lG"] = {
function() vim.lsp.buf.workspace_symbol() end,
desc = "List symbols"
}
end
if client.supports_method "textDocument/rename" then
lsp_mappings.n["<leader>lr"] = {
function() vim.lsp.buf.rename() end,
desc = "Rename symbol",
}
end
-- TODO: Check this on 0.10.0 release
if client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens then
vim.b[bufnr].semantic_tokens_enabled = true
lsp_mappings.n["<leader>mY"] = {
function()
vim.b[bufnr].semantic_tokens_enabled = not vim.b[bufnr].semantic_tokens_enabled
for _, active_client in ipairs(vim.lsp.get_active_clients { bufnr = bufnr }) do
if active_client.server_capabilities.semanticTokensProvider then
vim.lsp.semantic_tokens[vim.b[bufnr].semantic_tokens_enabled and "start" or "stop"](bufnr,
active_client.id)
end
end
end,
desc = "Toggle LSP semantic highlight (buffer)",
}
end
if client.supports_method("textDocument/formatting") then
lsp_mappings.n["<leader>lf"] = {
function()
vim.lsp.buf.format(require("config.lsp.format"))
end,
desc = "Format buffer",
}
lsp_mappings.v["<leader>lf"] = lsp_mappings.n["<leader>lf"]
end
if client.supports_method("textDocument/documentHighlight") then
add_buffer_autocmd("lsp_document_highlight", bufnr, {
{
events = { "CursorHold", "CursorHoldI" },
desc = "highlight references when cursor holds",
callback = function()
if not has_capability("textDocument/documentHighlight", { bufnr = bufnr }) then
del_buffer_autocmd("lsp_document_highlight", bufnr)
return
end
vim.lsp.buf.document_highlight()
end,
},
{
events = { "CursorMoved", "CursorMovedI", "BufLeave" },
desc = "clear references when cursor moves",
callback = function() vim.lsp.buf.clear_references() end,
},
})
end
if client.supports_method("textDocument/hover") then
-- TODO: Check this on 0.10.0 release
if vim.fn.has "nvim-0.10" == 0 then
lsp_mappings.n["K"] = {
function() vim.lsp.buf.hover() end,
desc = "Hover symbol",
}
end
end
if client.supports_method("textDocument/inlayHint") then
if vim.b.inlay_hints_enabled == nil then vim.b.inlay_hints_enabled = true end
-- TODO: Check this on 0.10.0 release
if vim.lsp.inlay_hint then
if vim.b.inlay_hints_enabled then vim.lsp.inlay_hint.enable(bufnr, true) end
lsp_mappings.n["<leader>mH"] = {
function()
vim.b[bufnr].inlay_hints_enabled = not vim.b[bufnr].inlay_hints_enabled
if vim.lsp.inlay_hint then
vim.lsp.inlay_hint.enable(bufnr, vim.b[bufnr].inlay_hints_enabled)
end
end,
desc = "Toggle inlay hints",
}
end
end
if client.supports_method "textDocument/signatureHelp" then
lsp_mappings.n["<leader>lh"] = {
function() vim.lsp.buf.signature_help() end,
desc = "Signature help",
}
end
if M.is_available "telescope.nvim" then
if lsp_mappings.n.gd then
lsp_mappings.n.gd[1] = function() require("telescope.builtin").lsp_definitions() end
end
if lsp_mappings.n.gI then
lsp_mappings.n.gI[1] = function() require("telescope.builtin").lsp_implementations() end
end
if lsp_mappings.n.gr then
lsp_mappings.n.gr[1] = function() require("telescope.builtin").lsp_references() end
end
if lsp_mappings.n["<leader>lR"] then
lsp_mappings.n["<leader>lR"][1] = function() require("telescope.builtin").lsp_references() end
end
if lsp_mappings.n.gy then
lsp_mappings.n.gy[1] = function() require("telescope.builtin").lsp_type_definitions() end
end
if lsp_mappings.n["<leader>lG"] then
lsp_mappings.n["<leader>lG"][1] = function()
vim.ui.input({ prompt = "Symbol Query: (leave empty for word under cursor)" }, function(query)
if query then
-- word under cursor if given query is empty
if query == "" then query = vim.fn.expand "<cword>" end
require("telescope.builtin").lsp_workspace_symbols {
query = query,
prompt_title = ("Find word (%s)"):format(query),
}
end
end)
end
end
end
if not vim.tbl_isempty(lsp_mappings.v) then
lsp_mappings.v["<leader>l"] = { desc = " " .. icons.ui.Note .. " LSP" }
end
M.set_mappings(lsp_mappings, { buffer = bufnr })
end
return M

View file

@ -10,7 +10,7 @@ M.dependencies = {
"nvim-autopairs",
}
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
local opts = function()
local has_words_before = function()

View file

@ -5,7 +5,7 @@ M.dependencies = {
"nvim-dap-ui",
}
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.config = function()
local icons = require('config.icons')

View file

@ -1,6 +1,6 @@
local M = { "stevearc/aerial.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.opts = {
attach_mode = "global",

View file

@ -1,5 +1,6 @@
return {
{ "folke/neodev.nvim", lazy = true },
{ "folke/neoconf.nvim", config = true },
{ "folke/neodev.nvim", config = true },
require('plugins.lsp.lspconfig'),
require('plugins.lsp.mason'),
require('plugins.lsp.mason-lspconfig'),

View file

@ -1,13 +1,7 @@
local M = { "neovim/nvim-lspconfig" }
M.dependencies = { "folke/neoconf.nvim", "mason-lspconfig.nvim" }
M.dependencies = { "mason-lspconfig.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.cmd = function(_, cmds)
if require("funcs").is_available("neoconf.nvim") then
table.insert(cmds, "Neoconf")
end
end
M.event = { "BufReadPost", "BufNewFile" }
return M

View file

@ -1,61 +1,42 @@
local M = { "williamboman/mason-lspconfig.nvim" }
local serverconf = require("config.lsp.servers")
M.dependencies = { "mason.nvim" }
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.documentationFormat = { "markdown", "plaintext" }
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.preselectSupport = true
capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = { "documentation", "detail", "additionalTextEdits" }
}
capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
local function merge(table, overwrite)
overwrite = overwrite or {}
return table and vim.tbl_deep_extend("force", table, overwrite) or overwrite
end
M.dependencies = { "mason.nvim", "neoconf.nvim", "neodev.nvim" }
M.cmd = { "LspInstall", "LspUninstall" }
local opts = {
ensure_installed = { "lua_ls", "bashls" },
handlers = {
function(server_name)
require("lspconfig")[server_name].setup({})
end,
["intelephense"] = function()
require("lspconfig")["intelephense"].setup({
init_options = {
storagePath = os.getenv('XDG_CACHE_HOME') .. '/intelephense',
globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licence.txt',
}
})
end,
["lua_ls"] = function()
require("lspconfig")["lua_ls"].setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
},
},
telemetry = {
enable = false,
},
maxPreload = 100000,
preloadFileSize = 10000,
},
},
})
end,
},
}
M.config = function()
local icons = require("config.icons")
local signs = {
{ name = "DiagnosticSignError", text = icons.DiagnosticError, texthl = "DiagnosticSignError" },
{ name = "DiagnosticSignWarn", text = icons.DiagnosticWarn, texthl = "DiagnosticSignWarn" },
{ name = "DiagnosticSignHint", text = icons.DiagnosticHint, texthl = "DiagnosticSignHint" },
{ name = "DiagnosticSignInfo", text = icons.DiagnosticInfo, texthl = "DiagnosticSignInfo" },
{ name = "DapStopped", text = icons.DapStopped, texthl = "DiagnosticWarn" },
{ name = "DapBreakpoint", text = icons.DapBreakpoint, texthl = "DiagnosticInfo" },
{ name = "DapBreakpointRejected", text = icons.DapBreakpointRejected, texthl = "DiagnosticError" },
{ name = "DiagnosticSignError", text = icons.DiagnosticError, texthl = "DiagnosticSignError" },
{ name = "DiagnosticSignWarn", text = icons.DiagnosticWarn, texthl = "DiagnosticSignWarn" },
{ name = "DiagnosticSignHint", text = icons.DiagnosticHint, texthl = "DiagnosticSignHint" },
{ name = "DiagnosticSignInfo", text = icons.DiagnosticInfo, texthl = "DiagnosticSignInfo" },
{ name = "DapStopped", text = icons.DapStopped, texthl = "DiagnosticWarn" },
{ name = "DapBreakpoint", text = icons.DapBreakpoint, texthl = "DiagnosticInfo" },
{ name = "DapBreakpointRejected", text = icons.DapBreakpointRejected, texthl = "DiagnosticError" },
{ name = "DapBreakpointCondition", text = icons.DapBreakpointCondition, texthl = "DiagnosticInfo" },
{ name = "DapLogPoint", text = icons.DapLogPoint, texthl = "DiagnosticInfo" },
{ name = "DapLogPoint", text = icons.DapLogPoint, texthl = "DiagnosticInfo" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, sign)
@ -86,12 +67,22 @@ M.config = function()
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded", silent = true })
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded", silent = true })
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{ border = "rounded", silent = true }
)
local mlsp = require('mason-lspconfig')
mlsp.setup({ ensure_installed = opts.ensure_installed })
mlsp.setup_handlers(opts.handlers)
mlsp.setup({ ensure_installed = serverconf.required })
mlsp.setup_handlers({
function(server)
local ls = require("lspconfig")[server]
local ls_opts = merge(ls, { capabilities = capabilities, on_attach = require("funcs").lsp_on_attach })
local opts = merge(ls_opts, serverconf.handlers[server])
require("lspconfig")[server].setup(opts)
end
})
end
return M

View file

@ -1,7 +1,7 @@
local M = { "jay-babu/mason-null-ls.nvim" }
M.cmd = { "NullLsInstall", "NullLsUninstall" }
M.dependencies = { "mason.nvim" }
M.opts = { handlers = {} }
M.config = true
return M

View file

@ -13,8 +13,6 @@ M.cmd = {
M.build = ":MasonUpdate"
M.keys = { { "<leader>lI", "<cmd>Mason<cr>", desc = "Mason" } }
M.opts = {
ui = {
border = "none",

View file

@ -1,27 +1,13 @@
local M = { "nvimtools/none-ls.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.dependencies = { "mason-null-ls.nvim" }
M.opts = function()
local nls = require("null-ls")
return {
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"),
sources = {
-- shell
nls.builtins.formatting.shfmt,
nls.builtins.code_actions.shellcheck,
-- python
nls.builtins.formatting.black,
-- perl
nls.builtins.formatting.perltidy,
-- Various (yaml, markdown, json among others)
nls.builtins.formatting.prettierd,
},
on_attach = function()
return { on_attach = require("funcs").lsp_on_attach }
end
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git", "ansible.cfg"),
on_attach = require("funcs").lsp_on_attach
}
end

View file

@ -1,6 +1,6 @@
local M = { "windwp/nvim-autopairs" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.opts = {
check_ts = true,

View file

@ -1,6 +1,6 @@
local M = { "akinsho/bufferline.nvim" }
M.event = { "BufRead", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.opts = function()
local icons = require('config.icons')

View file

@ -1,6 +1,6 @@
local M = { "norcalli/nvim-colorizer.lua" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.opts = { '*' }

View file

@ -1,6 +1,6 @@
local M = { "numToStr/Comment.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.opts = {
mappings = {

View file

@ -1,6 +1,6 @@
local M = { "lewis6991/gitsigns.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
local icons = require('config.icons')

View file

@ -1,6 +1,6 @@
local M = { "RRethy/vim-illuminate" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
local opts = {
providers = {

View file

@ -2,7 +2,7 @@ local M = { "lukas-reineke/indent-blankline.nvim" }
M.main = "ibl"
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
-- FIX: This keybind is broken and should be moved to config/keymaps.lua
-- M.keys = {

View file

@ -2,13 +2,14 @@ return {
{ "nvim-lua/plenary.nvim", lazy = true },
{ "kyazdani42/nvim-web-devicons", lazy = true },
{ "NMAC427/guess-indent.nvim" },
{ "JoosepAlviste/nvim-ts-context-commentstring" },
require('plugins.misc.alpha'),
require('plugins.misc.autopairs'),
require('plugins.misc.bufferline'),
require('plugins.misc.colorizer'),
require('plugins.misc.comment'),
require('plugins.misc.gitsigns'),
require('plugins.misc.illuminate'),
-- require('plugins.misc.illuminate'),
require('plugins.misc.indent-blankline'),
require('plugins.misc.lf'),
require('plugins.misc.lualine'),

View file

@ -1,6 +1,6 @@
local M = { "kylechui/nvim-surround" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.config = true

View file

@ -1,6 +1,6 @@
local M = { "folke/todo-comments.nvim" }
M.event = { "BufReadPre", "BufNewFile" }
M.event = { "BufReadPost", "BufNewFile" }
M.config = {
highlight = {

View file

@ -1,23 +1,114 @@
local M = { "nvim-treesitter/nvim-treesitter" }
M.event = { "BufReadPre", "BufNewFile" }
M.dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
"windwp/nvim-ts-autotag",
}
M.event = { "BufReadPost", "BufNewFile" }
M.build = ":TSUpdate"
M.cmd = {
"TSBufDisable",
"TSBufEnable",
"TSBufToggle",
"TSDisable",
"TSEnable",
"TSToggle",
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSModuleInfo",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
}
M.init = function(plugin)
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end
M.opts = {
ensure_installed = { "lua", "bash", "c" },
ensure_installed = {
"bash",
"c",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"vim",
"vimdoc",
},
autotag = { enable = true },
highlight = {
enable = true,
},
auto_install = true,
autopairs = {
enable = false,
},
context_commentstring = {
enable = true,
enable_autocmd = false,
incremental_selection = { enable = true },
indent = { enable = true },
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["ak"] = { query = "@block.outer", desc = "around block" },
["ik"] = { query = "@block.inner", desc = "inside block" },
["ac"] = { query = "@class.outer", desc = "around class" },
["ic"] = { query = "@class.inner", desc = "inside class" },
["a?"] = { query = "@conditional.outer", desc = "around conditional" },
["i?"] = { query = "@conditional.inner", desc = "inside conditional" },
["af"] = { query = "@function.outer", desc = "around function " },
["if"] = { query = "@function.inner", desc = "inside function " },
["al"] = { query = "@loop.outer", desc = "around loop" },
["il"] = { query = "@loop.inner", desc = "inside loop" },
["aa"] = { query = "@parameter.outer", desc = "around argument" },
["ia"] = { query = "@parameter.inner", desc = "inside argument" },
},
},
move = {
enable = true,
set_jumps = true,
goto_next_start = {
["]k"] = { query = "@block.outer", desc = "Next block start" },
["]f"] = { query = "@function.outer", desc = "Next function start" },
["]a"] = { query = "@parameter.inner", desc = "Next argument start" },
},
goto_next_end = {
["]K"] = { query = "@block.outer", desc = "Next block end" },
["]F"] = { query = "@function.outer", desc = "Next function end" },
["]A"] = { query = "@parameter.inner", desc = "Next argument end" },
},
goto_previous_start = {
["[k"] = { query = "@block.outer", desc = "Previous block start" },
["[f"] = { query = "@function.outer", desc = "Previous function start" },
["[a"] = { query = "@parameter.inner", desc = "Previous argument start" },
},
goto_previous_end = {
["[K"] = { query = "@block.outer", desc = "Previous block end" },
["[F"] = { query = "@function.outer", desc = "Previous function end" },
["[A"] = { query = "@parameter.inner", desc = "Previous argument end" },
},
},
swap = {
enable = true,
swap_next = {
[">K"] = { query = "@block.outer", desc = "Swap next block" },
[">F"] = { query = "@function.outer", desc = "Swap next function" },
[">A"] = { query = "@parameter.inner", desc = "Swap next argument" },
},
swap_previous = {
["<K"] = { query = "@block.outer", desc = "Swap previous block" },
["<F"] = { query = "@function.outer", desc = "Swap previous function" },
["<A"] = { query = "@parameter.inner", desc = "Swap previous argument" },
},
},
},
}
M.keys = {
{ "<leader>T", "<cmd>TSConfigInfo<cr>", desc = "Treesitter Info" }
}
return M

View file

@ -1,3 +1,3 @@
continue porting lsp_maps https://github.com/AstroNvim/AstroNvim/blob/8a019756cf45cb8f08dc11ce0396a577bd716936/lua/astronvim/utils/lsp.lua#L139
Continue checking for old keymaps
Configure Todo Telescope integration
Figure out why the theme breaks when you install a plugin