Merge branch 'dev' into mercury
nvim: add Telescope keymaps fix luassert prompt switch to lazy.nvim add TreeSitter parsers
This commit is contained in:
commit
4a47c79be2
@ -6,6 +6,7 @@
|
|||||||
require("globals") -- ./lua/globals.lua
|
require("globals") -- ./lua/globals.lua
|
||||||
require("utils") -- ./lua/utils.lua
|
require("utils") -- ./lua/utils.lua
|
||||||
require("settings") -- ./lua/settings.lua
|
require("settings") -- ./lua/settings.lua
|
||||||
require("plugin.packer") -- ./lua/plugin/packer.lua
|
|
||||||
require("maps") -- ./lua/maps.lua
|
require("maps") -- ./lua/maps.lua
|
||||||
require("statusline") -- ./lua/statusline.lua
|
require("statusline") -- ./lua/statusline.lua
|
||||||
|
require("plugin")
|
||||||
|
require("lazy").setup("plugin")
|
||||||
|
@ -61,8 +61,8 @@ vim.keymap.set("n", "<leader><enter>",
|
|||||||
|
|
||||||
-- packer
|
-- packer
|
||||||
vim.keymap.set("n", "<leader>u",
|
vim.keymap.set("n", "<leader>u",
|
||||||
function() require("packer").sync() end,
|
function() require("lazy").sync() end,
|
||||||
{ desc = "Sync packer config and update plugins" }
|
{ desc = "Open up Lazy.nvim" }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- telescope
|
-- telescope
|
||||||
@ -90,6 +90,16 @@ vim.keymap.set("n", "<leader>tl",
|
|||||||
function() require("telescope.builtin").live_grep() end,
|
function() require("telescope.builtin").live_grep() end,
|
||||||
{ desc = "Grep interactively" }
|
{ desc = "Grep interactively" }
|
||||||
)
|
)
|
||||||
|
vim.keymap.set("n", "<leader>tk",
|
||||||
|
function() require("telescope.builtin").keymaps() end,
|
||||||
|
{ desc = "Search through keymaps" }
|
||||||
|
)
|
||||||
|
vim.keymap.set("n", "<leader>tx",
|
||||||
|
function() require("telescope.builtin").diagnostics(
|
||||||
|
{ buffnr = 0 }
|
||||||
|
) end,
|
||||||
|
{ desc = "Search through LSP diagnostics" }
|
||||||
|
)
|
||||||
|
|
||||||
-- colorscheme
|
-- colorscheme
|
||||||
vim.keymap.set("n", "<leader>s",
|
vim.keymap.set("n", "<leader>s",
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
-- Author : swytch
|
|
||||||
-- Created : Saturday Sept. 11, 2021 22:12:33 CET
|
|
||||||
-- License : GPLv3
|
|
||||||
-- Description : cmp plugin config file
|
|
||||||
|
|
||||||
local cmp = require("cmp")
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and
|
|
||||||
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
|
|
||||||
sub(col, col):match('%s') == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Custom item icons
|
|
||||||
local icons = { }
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
completion = {
|
|
||||||
autocomplete = true
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = "path" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "nvim_lua" },
|
|
||||||
{ name = "calc" },
|
|
||||||
{ name = "spell" },
|
|
||||||
{ name = "treesitter" },
|
|
||||||
},
|
|
||||||
formatting = {
|
|
||||||
format = function(entry, vim_item)
|
|
||||||
vim_item.menu = ({
|
|
||||||
nvim_lsp = "[lsp]",
|
|
||||||
nvim_lua = "[nvim]",
|
|
||||||
luasnip = "[snip]",
|
|
||||||
path = "[path]",
|
|
||||||
buffer = "[buff]",
|
|
||||||
calc = "[calc]",
|
|
||||||
spell = "[spel]",
|
|
||||||
treesitter = "[tree]",
|
|
||||||
})[entry.source.name]
|
|
||||||
return vim_item
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = {
|
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<C-e>"] = cmp.mapping.close(),
|
|
||||||
["<CR>"] = cmp.mapping.confirm({
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
}),
|
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if luasnip.expand_or_locally_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<C-n>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<C-p>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
},
|
|
||||||
view = {
|
|
||||||
entries = {name = 'custom', selection_order = 'near_cursor' }
|
|
||||||
},
|
|
||||||
}
|
|
17
.config/nvim/lua/plugin/colorscheme.lua
Normal file
17
.config/nvim/lua/plugin/colorscheme.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-- Author : swytch
|
||||||
|
-- Created : Sunday Jan. 29, 2023 00:50:17 CET
|
||||||
|
-- License : GPLv3
|
||||||
|
-- Description : colorscheme config file
|
||||||
|
|
||||||
|
local utils = require("utils")
|
||||||
|
local file = os.getenv("XDG_STATE_HOME") .. "/nvim_colorscheme"
|
||||||
|
local colorscheme = utils.lines_from(file)[0]
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
dir = "~/.local/src/astronomy.nvim",
|
||||||
|
opts = {
|
||||||
|
variant = colorscheme,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
@ -1,57 +1,21 @@
|
|||||||
-- Author : swytch
|
-- Author : swytch
|
||||||
-- Created : Tuesday Oct. 12, 2021 19:07:36 CET
|
-- Created : Sunday Jan. 29, 2023 00:20:31 CET
|
||||||
-- License : GPLv3
|
-- License : GPLv3
|
||||||
-- Description : Comment plugin config file
|
-- Description : Mini.comment plugin config file
|
||||||
|
|
||||||
require("Comment").setup {
|
return {
|
||||||
---Add a space b/w comment and the line
|
"echasnovski/mini.comment",
|
||||||
---@type boolean
|
version = "*",
|
||||||
padding = true,
|
opts = {
|
||||||
|
mappings = {
|
||||||
|
comment = "<leader>c",
|
||||||
|
|
||||||
---Lines to be ignored while comment/uncomment.
|
comment_line = "<leader><Space>",
|
||||||
---Could be a regex string or a function that returns a regex string.
|
|
||||||
---Example: Use '^$' to ignore empty lines
|
|
||||||
---@type string|function
|
|
||||||
ignore = nil,
|
|
||||||
|
|
||||||
---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode
|
text_object = "gc",
|
||||||
---@type table
|
},
|
||||||
mappings = {
|
|
||||||
---operator-pending mapping
|
|
||||||
---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}`
|
|
||||||
basic = true,
|
|
||||||
---extra mapping
|
|
||||||
---Includes `gco`, `gcO`, `gcA`
|
|
||||||
extra = true,
|
|
||||||
---extended mapping
|
|
||||||
---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
|
|
||||||
extended = false,
|
|
||||||
},
|
},
|
||||||
|
config = function(_, opts)
|
||||||
---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode
|
require("mini.comment").setup(opts)
|
||||||
---@type table
|
end,
|
||||||
toggler = {
|
|
||||||
---line-comment toggle
|
|
||||||
line = "<leader><Space>",
|
|
||||||
---block-comment toggle
|
|
||||||
block = "<leader>bb",
|
|
||||||
},
|
|
||||||
|
|
||||||
---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode
|
|
||||||
---@type table
|
|
||||||
opleader = {
|
|
||||||
---line-comment opfunc mapping
|
|
||||||
line = "<leader>c",
|
|
||||||
---block-comment opfunc mapping
|
|
||||||
block = "<leader>b",
|
|
||||||
},
|
|
||||||
|
|
||||||
---Pre-hook, called before commenting the line
|
|
||||||
---@type function|nil
|
|
||||||
pre_hook = nil,
|
|
||||||
|
|
||||||
---Post-hook, called after commenting is done
|
|
||||||
---@type function|nil
|
|
||||||
post_hook = nil,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
151
.config/nvim/lua/plugin/completion.lua
Normal file
151
.config/nvim/lua/plugin/completion.lua
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
-- Author : swytch
|
||||||
|
-- Created : Sunday Jan. 29, 00:03:53 CET
|
||||||
|
-- License : GPLv3
|
||||||
|
-- Description : completion plugin config file
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
opts = function()
|
||||||
|
local types = require("luasnip.util.types")
|
||||||
|
return {
|
||||||
|
history = true,
|
||||||
|
-- Update more often, :h events for more info.
|
||||||
|
updateevents = "TextChanged,TextChangedI",
|
||||||
|
ext_opts = {
|
||||||
|
[types.choiceNode] = {
|
||||||
|
active = {
|
||||||
|
virt_text = { { "●", "LuaSnipChoice" } },
|
||||||
|
},
|
||||||
|
inactive = {
|
||||||
|
virt_text = { { "●", "LuaSnipInactive" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[types.functionNode] = {
|
||||||
|
active = {
|
||||||
|
virt_text = { { "●", "LuaSnipFunction" } },
|
||||||
|
},
|
||||||
|
inactive = {
|
||||||
|
virt_text = { { "●", "LuaSnipInactive" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[types.insertNode] = {
|
||||||
|
active = {
|
||||||
|
virt_text = { { "●", "LuaSnipInsert" } },
|
||||||
|
},
|
||||||
|
inactive = {
|
||||||
|
virt_text = { { "●", "LuaSnipInactive" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- treesitter-hl has 100, use something higher (default is 200).
|
||||||
|
ext_base_prio = 200,
|
||||||
|
-- minimal increase in priority.
|
||||||
|
ext_prio_increase = 1,
|
||||||
|
enable_autosnippets = true,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
dependencies = {
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-nvim-lua",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-calc",
|
||||||
|
"ray-x/cmp-treesitter",
|
||||||
|
"f3fora/cmp-spell",
|
||||||
|
},
|
||||||
|
opts = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and
|
||||||
|
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
|
||||||
|
sub(col, col):match('%s') == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
completion = {
|
||||||
|
autocomplete = true
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "calc" },
|
||||||
|
{ name = "spell" },
|
||||||
|
{ name = "treesitter" },
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
vim_item.menu = ({
|
||||||
|
nvim_lsp = "[lsp]",
|
||||||
|
nvim_lua = "[nvim]",
|
||||||
|
luasnip = "[snip]",
|
||||||
|
path = "[path]",
|
||||||
|
buffer = "[buff]",
|
||||||
|
calc = "[calc]",
|
||||||
|
spell = "[spel]",
|
||||||
|
treesitter = "[tree]",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-e>"] = cmp.mapping.close(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
}),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-n>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-p>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
},
|
||||||
|
view = {
|
||||||
|
entries = { name = 'custom', selection_order = 'near_cursor' }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
}
|
20
.config/nvim/lua/plugin/init.lua
Normal file
20
.config/nvim/lua/plugin/init.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-- Author : swytch
|
||||||
|
-- Created : Friday Mar 12, 2021 22:28:34 CET
|
||||||
|
-- License : GPLv3
|
||||||
|
-- Description : neovim packer config file
|
||||||
|
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
vim.fn.system({
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--filter=blob:none",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
"--branch=stable", -- latest stable release
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
@ -4,59 +4,7 @@
|
|||||||
-- Description : neovim global lsp config file
|
-- Description : neovim global lsp config file
|
||||||
|
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
_G.lsp_root_dir = vim.fn.stdpath("data") .. "/mason/bin"
|
||||||
local mason = require("mason")
|
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
|
||||||
|
|
||||||
local globals = require("globals")
|
|
||||||
local signs = {
|
|
||||||
Error = globals.sign_error,
|
|
||||||
Warn = globals.sign_warn,
|
|
||||||
Hint = globals.sign_hint,
|
|
||||||
Info = globals.sign_info,
|
|
||||||
}
|
|
||||||
|
|
||||||
for type, icon in pairs(signs) do
|
|
||||||
local hl = "DiagnosticSign" .. type
|
|
||||||
vim.fn.sign_define(hl, {
|
|
||||||
text = icon,
|
|
||||||
texthl = hl,
|
|
||||||
numhl = hl
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.diagnostic.config({
|
|
||||||
update_in_insert = true
|
|
||||||
})
|
|
||||||
|
|
||||||
local on_attach = function(_, bufnr)
|
|
||||||
local opts = { buffer = bufnr }
|
|
||||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
||||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
||||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
|
||||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
||||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
|
||||||
vim.keymap.set("n", "<leader>ln", vim.diagnostic.goto_next, opts)
|
|
||||||
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
|
|
||||||
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, opts)
|
|
||||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
|
||||||
vim.keymap.set("n", "<leader>wa",
|
|
||||||
vim.lsp.buf.add_workspace_folder, opts)
|
|
||||||
vim.keymap.set("n", "<leader>wr",
|
|
||||||
vim.lsp.buf.remove_workspace_folder, opts)
|
|
||||||
vim.keymap.set("n", "<leader>wl", function()
|
|
||||||
vim.inspect(vim.lsp.buf.list_workspace_folders())
|
|
||||||
end, opts)
|
|
||||||
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
|
|
||||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
|
||||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
|
||||||
vim.keymap.set("n", "<leader>so",
|
|
||||||
require("telescope.builtin").lsp_document_symbols, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
"clangd",
|
"clangd",
|
||||||
@ -65,31 +13,98 @@ local servers = {
|
|||||||
"texlab",
|
"texlab",
|
||||||
}
|
}
|
||||||
|
|
||||||
mason.setup({
|
return {
|
||||||
ui = {
|
|
||||||
icons = {
|
{
|
||||||
server_installed = "✓",
|
"neovim/nvim-lspconfig",
|
||||||
server_pending = "o",
|
dependencies = {
|
||||||
server_uninstalled = ""
|
"williamboman/mason.nvim",
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
underline = true,
|
||||||
|
update_in_insert = false,
|
||||||
|
severity_sort = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
local globals = require("globals")
|
||||||
|
|
||||||
|
local signs = {
|
||||||
|
Error = globals.sign_error,
|
||||||
|
Warn = globals.sign_warn,
|
||||||
|
Hint = globals.sign_hint,
|
||||||
|
Info = globals.sign_info,
|
||||||
|
}
|
||||||
|
|
||||||
|
for type, icon in pairs(signs) do
|
||||||
|
local hl = "DiagnosticSign" .. type
|
||||||
|
vim.fn.sign_define(hl, {
|
||||||
|
text = icon,
|
||||||
|
texthl = hl,
|
||||||
|
numhl = hl
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_attach = function(_, bufnr)
|
||||||
|
local opts = { buffer = bufnr }
|
||||||
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set("n", "<leader>ln", vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, opts)
|
||||||
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap.set("n", "<leader>wa",
|
||||||
|
vim.lsp.buf.add_workspace_folder, opts)
|
||||||
|
vim.keymap.set("n", "<leader>wr",
|
||||||
|
vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
|
vim.keymap.set("n", "<leader>wl", function()
|
||||||
|
vim.inspect(vim.lsp.buf.list_workspace_folders())
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set("n", "<leader>so",
|
||||||
|
require("telescope.builtin").lsp_document_symbols, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- nvim-cmp supports additional completion capabilities
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||||
|
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
local opts = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
|
||||||
|
local plugin = string.format("plugin.lsp.%s", server)
|
||||||
|
require(plugin).setup(opts)
|
||||||
|
|
||||||
|
lspconfig[server].setup(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
require("mason-lspconfig").setup({ ensure_installed = servers })
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
cmd = "Mason",
|
||||||
|
-- opts = { ensure_installed = servers },
|
||||||
|
opts = {
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
server_installed = "✓",
|
||||||
|
server_pending = "o",
|
||||||
|
server_uninstalled = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
_G.lsp_root_dir = vim.fn.stdpath("data") .. "/mason/bin"
|
|
||||||
|
|
||||||
mason_lspconfig.setup({
|
|
||||||
ensure_installed = servers,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
for _, server in ipairs(servers) do
|
|
||||||
local opts = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
}
|
|
||||||
|
|
||||||
local plugin = string.format("plugin.lsp.%s", server)
|
|
||||||
require(plugin).setup(opts)
|
|
||||||
|
|
||||||
lspconfig[server].setup(opts)
|
|
||||||
end
|
|
||||||
|
@ -34,6 +34,7 @@ M.setup = function(opts)
|
|||||||
-- Make the server aware of Neovim runtime files
|
-- Make the server aware of Neovim runtime files
|
||||||
library =
|
library =
|
||||||
vim.api.nvim_get_runtime_file("", true),
|
vim.api.nvim_get_runtime_file("", true),
|
||||||
|
checkThirdParty = false,
|
||||||
},
|
},
|
||||||
-- Do not send telemetry data containing a randomized but
|
-- Do not send telemetry data containing a randomized but
|
||||||
-- unique identifier
|
-- unique identifier
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
-- Author : swytch
|
|
||||||
-- Created : Friday Nov. 19, 2021 23:27:24 CET
|
|
||||||
-- License : GPLv3
|
|
||||||
-- Description : luasnip config file
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
-- some shorthands...
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local c = ls.choice_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local l = require("luasnip.extras").lambda
|
|
||||||
local r = require("luasnip.extras").rep
|
|
||||||
local p = require("luasnip.extras").partial
|
|
||||||
local m = require("luasnip.extras").match
|
|
||||||
local n = require("luasnip.extras").nonempty
|
|
||||||
local dl = require("luasnip.extras").dynamic_lambda
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local types = require("luasnip.util.types")
|
|
||||||
local conds = require("luasnip.extras.expand_conditions")
|
|
||||||
|
|
||||||
-- Every unspecified option will be set to the default.
|
|
||||||
ls.config.set_config({
|
|
||||||
history = true,
|
|
||||||
-- Update more often, :h events for more info.
|
|
||||||
updateevents = "TextChanged,TextChangedI",
|
|
||||||
ext_opts = {
|
|
||||||
[types.choiceNode] = {
|
|
||||||
active = {
|
|
||||||
virt_text = { { "●", "LuaSnipChoice" } },
|
|
||||||
},
|
|
||||||
inactive = {
|
|
||||||
virt_text = { { "●", "LuaSnipInactive" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[types.functionNode] = {
|
|
||||||
active = {
|
|
||||||
virt_text = { { "●", "LuaSnipFunction" } },
|
|
||||||
},
|
|
||||||
inactive = {
|
|
||||||
virt_text = { { "●", "LuaSnipInactive" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[types.insertNode] = {
|
|
||||||
active = {
|
|
||||||
virt_text = { { "●", "LuaSnipInsert" } },
|
|
||||||
},
|
|
||||||
inactive = {
|
|
||||||
virt_text = { { "●", "LuaSnipInactive" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- treesitter-hl has 100, use something higher (default is 200).
|
|
||||||
ext_base_prio = 200,
|
|
||||||
-- minimal increase in priority.
|
|
||||||
ext_prio_increase = 1,
|
|
||||||
enable_autosnippets = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
|
|
||||||
local function bash(_, _, command)
|
|
||||||
local file = io.popen(command, "r")
|
|
||||||
local res = {}
|
|
||||||
for line in file:lines() do
|
|
||||||
table.insert(res, line)
|
|
||||||
end
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Returns a snippet_node wrapped around an insert_node whose initial
|
|
||||||
-- text value is set to the current date in the desired format.
|
|
||||||
local function date_input(fmt)
|
|
||||||
local format = fmt or "%Y-%m-%d"
|
|
||||||
return sn(nil, i(1, os.date(format)))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- in a lua file: search lua-, then c-, then all-snippets.
|
|
||||||
ls.filetype_extend("lua", { "c" })
|
|
||||||
-- in a cpp file: search c-snippets, then all-snippets only (no cpp-snippets!!).
|
|
||||||
ls.filetype_set("cpp", { "c" })
|
|
@ -1,125 +0,0 @@
|
|||||||
-- Author : swytch
|
|
||||||
-- Created : Friday Mar 12, 2021 22:28:34 CET
|
|
||||||
-- License : GPLv3
|
|
||||||
-- Description : neovim packer config file
|
|
||||||
|
|
||||||
|
|
||||||
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
|
||||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
|
||||||
print("Cloning packer...")
|
|
||||||
PACKER_BOOTSTRAP = vim.fn.system({
|
|
||||||
"git",
|
|
||||||
"clone",
|
|
||||||
"--depth",
|
|
||||||
"1",
|
|
||||||
"https://github.com/wbthomason/packer.nvim",
|
|
||||||
install_path,
|
|
||||||
})
|
|
||||||
vim.cmd([[packadd packer.nvim]])
|
|
||||||
print("Done.")
|
|
||||||
end
|
|
||||||
|
|
||||||
local packer = require("packer")
|
|
||||||
|
|
||||||
packer.init({
|
|
||||||
display = {
|
|
||||||
working_sym = ' ', -- The symbol for a plugin being installed/updated
|
|
||||||
error_sym = ' ', -- The symbol for a plugin with an error in installation/updating
|
|
||||||
done_sym = ' ', -- The symbol for a plugin which has completed installation/updating
|
|
||||||
removed_sym = '- ', -- The symbol for an unused plugin which was removed
|
|
||||||
moved_sym = '→ ', -- The symbol for a plugin which was moved (e.g. from opt to start)
|
|
||||||
header_sym = '━ ', -- The symbol for the header line in packer's display
|
|
||||||
open_fn = function()
|
|
||||||
return require('packer.util').float({ border = "single" })
|
|
||||||
end, -- Display in a floating window
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local use = packer.use
|
|
||||||
|
|
||||||
return require("packer").startup(function()
|
|
||||||
-- packer manages itself
|
|
||||||
use "wbthomason/packer.nvim"
|
|
||||||
|
|
||||||
-- colorscheme
|
|
||||||
use {
|
|
||||||
"~/.local/src/astronomy.nvim",
|
|
||||||
config = function() require("colorscheme") end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- tree-sitter
|
|
||||||
use {
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
run = ":TSUpdate",
|
|
||||||
config = function() require("plugin.treesitter") end
|
|
||||||
}
|
|
||||||
|
|
||||||
use { -- Additional text objects via treesitter
|
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
||||||
after = 'nvim-treesitter',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- telescope
|
|
||||||
use {
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
requires = {
|
|
||||||
{
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope-fzf-native.nvim",
|
|
||||||
run = "make"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope-file-browser.nvim",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require("telescope")
|
|
||||||
require("telescope").load_extension("fzf")
|
|
||||||
require("telescope").load_extension("file_browser")
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- LSP
|
|
||||||
use {
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
requires = {
|
|
||||||
"williamboman/mason.nvim",
|
|
||||||
"williamboman/mason-lspconfig.nvim",
|
|
||||||
},
|
|
||||||
config = function() require("plugin.lsp") end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- auto completion
|
|
||||||
use {
|
|
||||||
"hrsh7th/nvim-cmp",
|
|
||||||
requires = {
|
|
||||||
{
|
|
||||||
"L3MON4D3/LuaSnip",
|
|
||||||
config = function()
|
|
||||||
require("plugin.luasnip") end
|
|
||||||
},
|
|
||||||
"saadparwaiz1/cmp_luasnip",
|
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
|
||||||
"hrsh7th/cmp-nvim-lua",
|
|
||||||
"hrsh7th/cmp-buffer",
|
|
||||||
"hrsh7th/cmp-path",
|
|
||||||
"hrsh7th/cmp-calc",
|
|
||||||
"ray-x/cmp-treesitter",
|
|
||||||
"f3fora/cmp-spell",
|
|
||||||
},
|
|
||||||
config = function() require("plugin.cmp") end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- commenting, simplified
|
|
||||||
use {
|
|
||||||
"numToStr/Comment.nvim",
|
|
||||||
config = function() require("plugin.comment") end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- automatically setup the config after cloning
|
|
||||||
if PACKER_BOOTSTRAP then
|
|
||||||
require("packer").sync()
|
|
||||||
end
|
|
||||||
end)
|
|
@ -1,22 +1,33 @@
|
|||||||
-- Author : swytch
|
-- Author : swytch
|
||||||
-- Created : Monday Dec. 26, 2022 18:39:16 CET
|
-- Created : Monday Dec. 26, 2022 18:39:16 CET
|
||||||
-- License : GPLv3
|
-- License : GPLv3
|
||||||
-- Description : treesitter config file
|
-- Description : telescope config file
|
||||||
|
|
||||||
require("telescope").setup {
|
return {
|
||||||
extensions = {
|
{
|
||||||
file_browser = {
|
"nvim-telescope/telescope.nvim",
|
||||||
theme = "ivy",
|
dependencies = {
|
||||||
-- disables netrw and use telescope-file-browser in its place
|
{
|
||||||
hijack_netrw = true,
|
"nvim-lua/plenary.nvim",
|
||||||
mappings = {
|
"nvim-telescope/telescope-file-browser.nvim",
|
||||||
["i"] = {
|
{
|
||||||
-- your custom insert mode mappings
|
"nvim-telescope/telescope-fzf-native.nvim",
|
||||||
},
|
build = "make"
|
||||||
["n"] = {
|
}
|
||||||
-- your custom normal mode mappings
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
opts = {
|
||||||
|
extensions = {
|
||||||
|
file_browser = {
|
||||||
|
theme = "ivy",
|
||||||
|
hijack_netrw = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("telescope").setup(opts)
|
||||||
|
require("telescope").load_extension("fzf")
|
||||||
|
require("telescope").load_extension("file_browser")
|
||||||
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,113 +3,126 @@
|
|||||||
-- License : GPLv3
|
-- License : GPLv3
|
||||||
-- Description : treesitter config file
|
-- Description : treesitter config file
|
||||||
|
|
||||||
require("nvim-treesitter.configs").setup {
|
return {
|
||||||
ensure_installed = { "c", "lua", "rust", "bash", "vim" },
|
"nvim-treesitter/nvim-treesitter",
|
||||||
highlight = {
|
dependencies = {
|
||||||
enable = true,
|
-- Additional text objects via treesitter
|
||||||
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
},
|
},
|
||||||
indent = {
|
build = ":TSUpdate",
|
||||||
enable = true,
|
opts = {
|
||||||
},
|
ensure_installed = {
|
||||||
incremental_selection = {
|
"c", "cpp", "lua", "rust", "bash", "vim", "latex", "python",
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
init_selection = "<C-Space>",
|
|
||||||
node_incremental = "<C-Space>",
|
|
||||||
scope_incremental = "<Tab>",
|
|
||||||
node_decremental = "<BS>",
|
|
||||||
},
|
},
|
||||||
},
|
highlight = {
|
||||||
textobjects = {
|
enable = true,
|
||||||
select = {
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
-- use the capture groups defined in textobjects.scm
|
init_selection = "<C-Space>",
|
||||||
["ap"] = {
|
node_incremental = "<C-Space>",
|
||||||
query = "@parameter.outer",
|
scope_incremental = "<Tab>",
|
||||||
desc = "Select parameter region"
|
node_decremental = "<BS>",
|
||||||
},
|
|
||||||
["ip"] = {
|
|
||||||
query = "@parameter.inner",
|
|
||||||
desc = "Select inner part of a parameter region"
|
|
||||||
},
|
|
||||||
["af"] = {
|
|
||||||
query = "@function.outer",
|
|
||||||
desc = "Select a function block"
|
|
||||||
},
|
|
||||||
["if"] = {
|
|
||||||
query = "@function.inner",
|
|
||||||
desc = "Select inner part of a function"
|
|
||||||
},
|
|
||||||
["ac"] = {
|
|
||||||
query = "@class.outer",
|
|
||||||
desc = "Select a class block"
|
|
||||||
},
|
|
||||||
["ic"] = {
|
|
||||||
query = "@class.inner",
|
|
||||||
desc = "Select inner part of a class"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
move = {
|
textobjects = {
|
||||||
enable = true,
|
select = {
|
||||||
set_jumps = true, -- whether to set jumps in the jumplist
|
enable = true,
|
||||||
goto_next_start = {
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||||
["]m"] = {
|
keymaps = {
|
||||||
query = "@function.outer",
|
-- use the capture groups defined in textobjects.scm
|
||||||
desc = "Jump to next function",
|
["ap"] = {
|
||||||
},
|
query = "@parameter.outer",
|
||||||
["])"] = {
|
desc = "Select parameter region"
|
||||||
query = "@class.outer",
|
},
|
||||||
desc = "Jump to next class",
|
["ip"] = {
|
||||||
|
query = "@parameter.inner",
|
||||||
|
desc = "Select inner part of a parameter region"
|
||||||
|
},
|
||||||
|
["af"] = {
|
||||||
|
query = "@function.outer",
|
||||||
|
desc = "Select a function block"
|
||||||
|
},
|
||||||
|
["if"] = {
|
||||||
|
query = "@function.inner",
|
||||||
|
desc = "Select inner part of a function"
|
||||||
|
},
|
||||||
|
["ac"] = {
|
||||||
|
query = "@class.outer",
|
||||||
|
desc = "Select a class block"
|
||||||
|
},
|
||||||
|
["ic"] = {
|
||||||
|
query = "@class.inner",
|
||||||
|
desc = "Select inner part of a class"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
goto_next_end = {
|
move = {
|
||||||
["]M"] = {
|
enable = true,
|
||||||
query = "@function.outer",
|
set_jumps = true, -- whether to set jumps in the jumplist
|
||||||
desc = "Jump after next function",
|
goto_next_start = {
|
||||||
|
["]m"] = {
|
||||||
|
query = "@function.outer",
|
||||||
|
desc = "Jump to next function",
|
||||||
|
},
|
||||||
|
["])"] = {
|
||||||
|
query = "@class.outer",
|
||||||
|
desc = "Jump to next class",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
["]]"] = {
|
goto_next_end = {
|
||||||
query = "@class.outer",
|
["]M"] = {
|
||||||
desc = "Jump after next class",
|
query = "@function.outer",
|
||||||
|
desc = "Jump after next function",
|
||||||
|
},
|
||||||
|
["]]"] = {
|
||||||
|
query = "@class.outer",
|
||||||
|
desc = "Jump after next class",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
goto_previous_start = {
|
||||||
|
["[m"] = {
|
||||||
|
query = "@function.outer",
|
||||||
|
desc = "Jump to previous function",
|
||||||
|
},
|
||||||
|
["[)"] = {
|
||||||
|
query = "@class.outer",
|
||||||
|
desc = "Jump to previous class",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
goto_previous_end = {
|
||||||
|
["[M"] = {
|
||||||
|
query = "@function.outer",
|
||||||
|
desc = "Jump after previous function",
|
||||||
|
},
|
||||||
|
["[]"] = {
|
||||||
|
query = "@class.outer",
|
||||||
|
desc = "Jump after previous class",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
goto_previous_start = {
|
swap = {
|
||||||
["[m"] = {
|
enable = true,
|
||||||
query = "@function.outer",
|
swap_next = {
|
||||||
desc = "Jump to previous function",
|
["<leader>a"] = {
|
||||||
|
query = "@parameter.inner",
|
||||||
|
desc = "Swap with next parameter",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
["[)"] = {
|
swap_previous = {
|
||||||
query = "@class.outer",
|
["<leader>A"] = {
|
||||||
desc = "Jump to previous class",
|
query = "@parameter.inner",
|
||||||
},
|
desc = "Swap with previous parameter",
|
||||||
},
|
},
|
||||||
goto_previous_end = {
|
|
||||||
["[M"] = {
|
|
||||||
query = "@function.outer",
|
|
||||||
desc = "Jump after previous function",
|
|
||||||
},
|
|
||||||
["[]"] = {
|
|
||||||
query = "@class.outer",
|
|
||||||
desc = "Jump after previous class",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
swap = {
|
|
||||||
enable = true,
|
|
||||||
swap_next = {
|
|
||||||
["<leader>a"] = {
|
|
||||||
query = "@parameter.inner",
|
|
||||||
desc = "Swap with next parameter",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
swap_previous = {
|
|
||||||
["<leader>A"] = {
|
|
||||||
query = "@parameter.inner",
|
|
||||||
desc = "Swap with previous parameter",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("nvim-treesitter.configs").setup(opts)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user