Merge remote-tracking branch 'origin/nixos' into nixos

This commit is contained in:
Moritz Böhme 2023-04-17 14:47:16 +02:00
commit 69454aba52
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
74 changed files with 943 additions and 945 deletions

View file

@ -1,39 +1,15 @@
require("impatient")
---merge tables
---@param ... table[]
---@return table
local function table_merge(...)
local tables_to_merge = { ... }
assert(#tables_to_merge > 1, "There should be at least two tables to merge them")
for k, t in ipairs(tables_to_merge) do
assert(type(t) == "table", string.format("Expected a table as function parameter %d", k))
end
local result = tables_to_merge[1]
for i = 2, #tables_to_merge do
local from = tables_to_merge[i]
for k, v in pairs(from) do
if type(v) == "table" then
result[k] = result[k] or {}
result[k] = table_merge(result[k], v)
else
result[k] = v
end
end
end
return result
end
vim.loader.enable()
-- Load custom treesitter grammar for org filetype
require("orgmode").setup_ts_grammar()
require("nvim-treesitter.configs").setup({
sync_install = false,
auto_install = false,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
-- Required for spellcheck, some LaTex highlights and
-- code block highlights that do not have ts grammar
additional_vim_regex_highlighting = { "org" },
},
})
@ -42,6 +18,7 @@ vim.api.nvim_create_autocmd("InsertEnter", {
callback = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
require("copilot_cmp").setup()
local default_sources = {
@ -97,7 +74,7 @@ vim.api.nvim_create_autocmd("InsertEnter", {
})
cmp.setup.filetype("org", {
sources = table_merge(default_sources, {
sources = vim.tbl_deep_extend("force", default_sources, {
{ name = "buffer", priority = 5 },
{ name = "orgmode", priority = 5 },
}),
@ -167,11 +144,8 @@ require("lspsaga").setup({
enable = false,
},
lightbulb = {
enable = true,
enable_in_insert = true,
sign = true,
sign_priority = 40,
virtual_text = false,
enable = false,
enable_in_insert = false,
},
})
@ -181,10 +155,7 @@ local on_attach_def = function(_, bufnr)
K = { "<cmd>Lspsaga hover_doc ++quiet<cr>", "show info" },
["<leader>"] = {
l = {
name = "lsp",
d = { "<cmd>Lspsaga show_cursor_diagnostics<cr>", "open diagnostic window" },
n = { "<cmd>Lspsaga diagnostic_jump_next<CR>", "next error" },
p = { "<cmd>Lspsaga diagnostic_jump_prev<CR>", "prev error" },
c = { "<cmd>Lspsaga code_action<cr>", "code action" },
r = { "<cmd>Lspsaga rename<cr>", "rename" },
i = { "<cmd>Lspsaga hover_doc ++keep<cr>", "show info (sticky)" },
@ -196,27 +167,23 @@ local on_attach_def = function(_, bufnr)
mode = { "n", "v" },
},
},
w = {
name = "workspace",
a = { vim.lsp.buf.add_workspace_folder, "add workspace folder" },
r = { vim.lsp.buf.remove_workspace_folder, "remove workspace folder" },
l = {
function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end,
"list workspace folders",
},
},
t = {
name = "toggle",
l = { lsp_lines.toggle, "lsp lines" },
},
},
g = {
name = "goto",
d = { "<cmd>Lspsaga peek_definition<cr>", "definition" },
t = { "<cmd>Lspsaga peek_type_definition<cr>", "type defininition" },
h = { "<cmd>Lspsaga lsp_finder<CR>", "lsp finder" },
d = { "<cmd>Lspsaga peek_definition<cr>", "Goto definition" },
t = { "<cmd>Lspsaga peek_type_definition<cr>", "Goto type defininition" },
h = { "<cmd>Lspsaga lsp_finder<CR>", "Lsp finder" },
r = { "<cmd>Telescope lsp_references<cr>", "Goto reference" },
D = { vim.lsp.buf.declaration, "Goto declaration" },
I = { "<cmd>Telescope lsp_implementations<cr>", "Goto implementation" },
},
["["] = {
d = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Previous diagnostic" },
},
["]"] = {
d = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Next diagnostic" },
},
}, { buffer = bufnr, silent = true })
end
@ -234,7 +201,7 @@ local lspconfig_default_options = {
---@param options table
---@return nil
local function lspconfig_setup(lsp, options)
local final_options = table_merge(lspconfig_default_options, options)
local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options)
lspconfig[lsp].setup(final_options)
end