Compare commits
10 Commits
dec66a2f3a
...
db3a1827a4
Author | SHA1 | Date | |
---|---|---|---|
db3a1827a4 | |||
c73880bf90 | |||
705e3f52fd | |||
30c06d3adf | |||
9d088fe9d5 | |||
6655553eba | |||
6f9391fe56 | |||
df7988e8dd | |||
d1074eeca2 | |||
31cdc5d052 |
4
init.lua
4
init.lua
@ -1,3 +1,5 @@
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Allow loading */init.lua files
|
||||
package.path = "./?/init.lua;"..package.path
|
||||
|
||||
@ -17,5 +19,5 @@ require("personal.add-guard")
|
||||
require("personal.cmacro-align")
|
||||
|
||||
-- THEME_BEGIN
|
||||
vim.cmd("colorscheme srcery")
|
||||
cmd("colorscheme srcery")
|
||||
-- THEME_END
|
@ -1,7 +1,7 @@
|
||||
return {
|
||||
'jenterkin/vim-autosource',
|
||||
config = function()
|
||||
local user = os.getenv("USER")
|
||||
vim.g.autosource_hashdir = '/home/'..user..'/.cache/vim-autosource/hashes'
|
||||
local data = vim.fn.stdpath("data")
|
||||
vim.g.autosource_hashdir = data .. '/vim-autosource/hashes'
|
||||
end
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ return {
|
||||
"sindrets/diffview.nvim",
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
config = function()
|
||||
require("diffview").setup{
|
||||
enhanced_diff_hl = true
|
||||
}
|
||||
require("legendary").command{
|
||||
":DiffviewOpen", description = "Open diff view"
|
||||
}
|
||||
|
11
lua/config/doxygen-tk.lua
Normal file
11
lua/config/doxygen-tk.lua
Normal file
@ -0,0 +1,11 @@
|
||||
return {
|
||||
"vim-scripts/DoxygenToolkit.vim",
|
||||
config = function()
|
||||
vim.g.DoxygenToolkit_startCommentTag = "/// "
|
||||
vim.g.DoxygenToolkit_interCommentTag = "/// "
|
||||
vim.g.DoxygenToolkit_endCommentTag = ""
|
||||
vim.g.DoxygenToolkit_startCommentBlock = "// "
|
||||
vim.g.DoxygenToolkit_interCommentBlock = "// "
|
||||
vim.g.DoxygenToolkit_endCommentBlock = ""
|
||||
end
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
return {
|
||||
'tpope/vim-fugitive',
|
||||
config = function ()
|
||||
-- TODO: Add most commonly used fugitive bindings
|
||||
require("legendary").keymaps{
|
||||
{"<leader>gg", ":G<cr>", description = "Open fugitive", opts = {silent = true}}
|
||||
}
|
||||
end
|
||||
}
|
26
lua/config/git-conflict.lua
Normal file
26
lua/config/git-conflict.lua
Normal file
@ -0,0 +1,26 @@
|
||||
return {
|
||||
'akinsho/git-conflict.nvim',
|
||||
tag = "*",
|
||||
config = function()
|
||||
require('git-conflict').setup{
|
||||
default_mappings = false
|
||||
}
|
||||
|
||||
|
||||
require("legendary").keymaps{
|
||||
{
|
||||
itemgroup = "git-conflict",
|
||||
description = "Git conflict",
|
||||
icon = "",
|
||||
keymaps = {
|
||||
{ 'co', '<Plug>(git-conflict-ours)', description = "choose ours" },
|
||||
{ 'ct', '<Plug>(git-conflict-theirs)', description = "choose theirs" },
|
||||
{ 'cb', '<Plug>(git-conflict-both)', description = "choose both" },
|
||||
{ 'c0', '<Plug>(git-conflict-none)', description = "choose none" },
|
||||
{ ']x', '<Plug>(git-conflict-prev-conflict)', description = "move to previous conflict" },
|
||||
{ '[x', '<Plug>(git-conflict-next-conflict)', description = "move to next conflict" },
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
8
lua/config/lazygit.lua
Normal file
8
lua/config/lazygit.lua
Normal file
@ -0,0 +1,8 @@
|
||||
return {
|
||||
'kdheepak/lazygit.nvim',
|
||||
config = function ()
|
||||
require("legendary").keymaps{
|
||||
{"<leader>gg", ":LazyGit<cr>", description = "Open lazygit", opts = {silent = true}}
|
||||
}
|
||||
end
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
local M = {}
|
||||
local cfg = {}
|
||||
|
||||
-- debounce_text_changes = delay, between changing something and lsp updating
|
||||
M.flags = { debounce_text_changes = 150 }
|
||||
cfg.flags = { debounce_text_changes = 150 }
|
||||
|
||||
local general_settings = { }
|
||||
M.server_init_options = {
|
||||
cfg.server_init_options = {
|
||||
efm = {
|
||||
documentFormatting = true
|
||||
}
|
||||
}
|
||||
|
||||
M.server_settings = {
|
||||
cfg.server_settings = {
|
||||
efm = {
|
||||
rootMarkers = {".git/"},
|
||||
languages = {
|
||||
@ -84,14 +84,14 @@ M.server_settings = {
|
||||
}
|
||||
|
||||
-- Apply general settings for each server
|
||||
for _, settings in ipairs(M.server_settings) do
|
||||
M.server_settings = vim.tbl_deep_extend("keep", settings, general_settings)
|
||||
for _, settings in ipairs(cfg.server_settings) do
|
||||
cfg.server_settings = vim.tbl_deep_extend("keep", settings, general_settings)
|
||||
end
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
function M.on_attach(client, bufnr)
|
||||
function cfg.on_attach(client, bufnr)
|
||||
-- Mappings.
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr}
|
||||
|
||||
@ -137,7 +137,7 @@ function M.on_attach(client, bufnr)
|
||||
-- autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||
end
|
||||
|
||||
function M.get_capabilities()
|
||||
function cfg.get_capabilities()
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
if packer_plugins['cmp-nvim-lsp'] and packer_plugins['cmp-nvim-lsp'].loaded then
|
||||
@ -147,7 +147,7 @@ function M.get_capabilities()
|
||||
return capabilities
|
||||
end
|
||||
|
||||
function M.on_init(initialize_params, config)
|
||||
function cfg.on_init(initialize_params, config)
|
||||
-- print("lsp init")
|
||||
|
||||
-- TODO: Load settings from ".lspconfig.json" for each projects settings
|
||||
@ -155,18 +155,12 @@ function M.on_init(initialize_params, config)
|
||||
-- https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings
|
||||
end
|
||||
|
||||
function M.get_server_settings(name)
|
||||
return M.server_settings[name]
|
||||
function cfg.get_server_settings(name)
|
||||
return cfg.server_settings[name]
|
||||
end
|
||||
|
||||
function M.get_server_init_options(name)
|
||||
return M.server_init_options[name]
|
||||
function cfg.get_server_init_options(name)
|
||||
return cfg.server_init_options[name]
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: empty-block
|
||||
if packer_plugins['nvim-lsp-installer'] and packer_plugins['nvim-lsp-installer'].loaded then
|
||||
-- local lspconfig = require('lspconfig')
|
||||
-- TODO: Manually do "server:setup{}" if lspinstaller is not loaded
|
||||
end
|
||||
|
||||
return M
|
||||
return cfg
|
||||
|
@ -1,39 +0,0 @@
|
||||
local lspconfig_config = require('config.lspconfig')
|
||||
local lsp_installer = require('nvim-lsp-installer')
|
||||
local lsp_installer_servers = require('nvim-lsp-installer.servers')
|
||||
|
||||
-- local autoinstall_servers = {"sumneko_lua", "efm"}
|
||||
local autoinstall_servers = {"sumneko_lua"}
|
||||
for _, name in ipairs(autoinstall_servers) do
|
||||
local ok, server = lsp_installer_servers.get_server(name)
|
||||
if ok and not server:is_installed() then
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
|
||||
local capabilities = lspconfig_config.get_capabilities()
|
||||
|
||||
for _, server in ipairs(lsp_installer.get_installed_servers()) do
|
||||
local opts = {
|
||||
root_dir = function()
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
init_options = lspconfig_config.get_server_init_options(server.name),
|
||||
on_attach = lspconfig_config.on_attach,
|
||||
on_init = lspconfig_config.on_init,
|
||||
flags = lspconfig_config.flags,
|
||||
capabilities = capabilities,
|
||||
settings = lspconfig_config.get_server_settings(server.name)
|
||||
}
|
||||
|
||||
if server.name == "rust_analyzer" then
|
||||
local has_rust_tools, rust_tools = pcall(require, "rust-tools")
|
||||
if has_rust_tools then
|
||||
rust_tools.setup({ server = opts })
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
|
||||
server:setup(opts)
|
||||
::continue::
|
||||
end
|
@ -11,8 +11,8 @@ return {
|
||||
}
|
||||
}
|
||||
|
||||
require("legendary").keymap{
|
||||
"<C-x>", lsp_signature.toggle_float_win, description="Toggle signature float"
|
||||
}
|
||||
-- require("legendary").keymap{
|
||||
-- "<super>x", lsp_signature.toggle_float_win, description="Toggle signature float"
|
||||
-- }
|
||||
end
|
||||
}
|
||||
|
39
lua/config/mason-lspconfig.lua
Normal file
39
lua/config/mason-lspconfig.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local lspconfig_config = require('config.lspconfig')
|
||||
|
||||
local function get_options(server_name)
|
||||
return {
|
||||
root_dir = function()
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
init_options = lspconfig_config.get_server_init_options(server_name),
|
||||
on_attach = lspconfig_config.on_attach,
|
||||
on_init = lspconfig_config.on_init,
|
||||
flags = lspconfig_config.flags,
|
||||
capabilities = capabilities,
|
||||
settings = lspconfig_config.get_server_settings(server_name)
|
||||
}
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup()
|
||||
require("mason-lspconfig").setup_handlers{
|
||||
function (server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup(get_options(server_name))
|
||||
end,
|
||||
["rust_analyzer"] = function ()
|
||||
local opts = get_options(server_name)
|
||||
|
||||
local has_rust_tools, rust_tools = pcall(require, "rust-tools")
|
||||
if has_rust_tools then
|
||||
rust_tools.setup({
|
||||
server = opts,
|
||||
tools = {
|
||||
inlay_hints = {
|
||||
auto = false
|
||||
}
|
||||
}
|
||||
})
|
||||
else
|
||||
require("lspconfig")[server_name].setup(opts)
|
||||
end
|
||||
end
|
||||
}
|
1
lua/config/mason.lua
Normal file
1
lua/config/mason.lua
Normal file
@ -0,0 +1 @@
|
||||
require("mason").setup()
|
@ -86,6 +86,23 @@ if fzfPlugin and fzfPlugin.loaded then
|
||||
telescope.load_extension('fzf')
|
||||
end
|
||||
|
||||
local function get_vtext()
|
||||
local prev_regv = vim.fn.getreg('v')
|
||||
vim.cmd('noau normal! "vy"')
|
||||
local text = vim.fn.getreg('v')
|
||||
vim.fn.setreg("v", prev_regv)
|
||||
|
||||
text = string.gsub(text, "\n", "")
|
||||
if #text > 0 then
|
||||
return text
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local function escape_sed_symbols(text)
|
||||
return text:gsub("[.()%[%]]", "\\%1")
|
||||
end
|
||||
|
||||
local keymaps = {
|
||||
-- Search project files
|
||||
@ -98,7 +115,13 @@ local keymaps = {
|
||||
{"<leader>ce", edit_config, description = "Edit neovim config" },
|
||||
|
||||
-- Grep string
|
||||
{ "<leader>fw", function() builtin.live_grep() end, description = "Grep" },
|
||||
{ "<leader>fw", {
|
||||
n = function() builtin.live_grep() end,
|
||||
v = function(a)
|
||||
local text = escape_sed_symbols(get_vtext())
|
||||
builtin.live_grep{ default_text = text }
|
||||
end
|
||||
}, description = "Grep" },
|
||||
|
||||
-- Change colorscheme
|
||||
{ "<leader>cs", function() builtin.colorscheme() end, description = "Change colorscheme" },
|
||||
|
@ -3,6 +3,9 @@ return {
|
||||
run = function() require('nvim-treesitter.install').update{ with_sync = true } end,
|
||||
config = function ()
|
||||
local treesitter = require("nvim-treesitter.configs")
|
||||
if vim.fn.has("win32") then
|
||||
require('nvim-treesitter.install').compilers = { "clang" }
|
||||
end
|
||||
|
||||
treesitter.setup{
|
||||
highlight = { enable = true },
|
||||
|
15
lua/config/ufo.lua
Normal file
15
lua/config/ufo.lua
Normal file
@ -0,0 +1,15 @@
|
||||
return {
|
||||
"kevinhwang91/nvim-ufo",
|
||||
requires = {"kevinhwang91/promise-async", "nvim-treesitter/nvim-treesitter"},
|
||||
config = function ()
|
||||
local default = {"treesitter", "indent"}
|
||||
local filetypes = { c = {'indent'} }
|
||||
|
||||
require("ufo").setup({
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return filetypes[filetype] or default
|
||||
end
|
||||
})
|
||||
vim.api.nvim_set_hl(0, "UfoFoldedBg", { link = "ColorColumn" })
|
||||
end
|
||||
}
|
@ -138,3 +138,14 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
vim.api.nvim_buf_set_option(data.buf, 'softtabstop', 2)
|
||||
end
|
||||
})
|
||||
|
||||
-- Override `ft` for .h files to `c`
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }),
|
||||
pattern = "cpp",
|
||||
callback = function(data)
|
||||
if data.file:match("%.h$") then
|
||||
vim.api.nvim_buf_set_option(data.buf, "ft", "c")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -18,7 +18,7 @@ return function(use)
|
||||
use_config "lsputils"
|
||||
use_config "luasnip"
|
||||
use_config "trouble"
|
||||
use_config "fugitive"
|
||||
use_config "lazygit"
|
||||
use_config "gitsigns"
|
||||
use_config "nvim-tree"
|
||||
use_config "autosource"
|
||||
@ -31,6 +31,9 @@ return function(use)
|
||||
use_config "treesitter"
|
||||
use_config "ts-playground"
|
||||
use_config "diffview"
|
||||
use_config "git-conflict"
|
||||
use_config "doxygen-tk"
|
||||
-- use_config "ufo"
|
||||
|
||||
use {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
@ -39,20 +42,25 @@ return function(use)
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"kyazdani42/nvim-web-devicons",
|
||||
"nvim-telescope/telescope-ui-select.nvim",
|
||||
{"nvim-telescope/telescope-fzf-native.nvim", run = "make"}
|
||||
{"nvim-telescope/telescope-fzf-native.nvim", run = "make", disable = vim.fn.has("win32")}
|
||||
},
|
||||
load_config = true
|
||||
}
|
||||
|
||||
use {
|
||||
"neovim/nvim-lspconfig",
|
||||
config_name = "lspconfig"
|
||||
}
|
||||
|
||||
use {
|
||||
'williamboman/nvim-lsp-installer',
|
||||
"williamboman/mason.nvim",
|
||||
requires = 'neovim/nvim-lspconfig',
|
||||
config_name = "lspinstaller"
|
||||
config_name = "mason"
|
||||
}
|
||||
use {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
requires = "williamboman/mason.nvim",
|
||||
config_name = "mason-lspconfig"
|
||||
}
|
||||
use {
|
||||
"neovim/nvim-lspconfig",
|
||||
requires = "williamboman/mason-lspconfig.nvim",
|
||||
--config_name = "lspconfig"
|
||||
}
|
||||
|
||||
use {
|
||||
|
Loading…
Reference in New Issue
Block a user