1
0

Compare commits

...

10 Commits

Author SHA1 Message Date
db3a1827a4 update config to work on windows 2023-05-11 17:31:02 +03:00
c73880bf90 fix theme 2023-05-11 17:31:02 +03:00
705e3f52fd add greping with selected text 2023-05-11 17:31:02 +03:00
30c06d3adf update config 2023-05-11 17:31:02 +03:00
9d088fe9d5 disable ufo 2023-05-11 17:31:02 +03:00
6655553eba replace deprecated function 2023-05-11 17:31:02 +03:00
6f9391fe56 setup ufo 2023-05-11 17:31:02 +03:00
df7988e8dd add lazygit integration 2023-05-11 17:31:02 +03:00
d1074eeca2 switch to mason.nvim 2023-05-11 17:31:02 +03:00
31cdc5d052 update keybind 2023-05-11 17:31:02 +03:00
17 changed files with 197 additions and 101 deletions

View File

@ -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")
-- THEME_END
cmd("colorscheme srcery")
-- THEME_END

View File

@ -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
}

View File

@ -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
View 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
}

View File

@ -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
}

View 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
View 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
}

View File

@ -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,19 +84,19 @@ 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)
-- Mappings.
local opts = { noremap = true, silent = true, buffer = bufnr}
function cfg.on_attach(client, bufnr)
-- Mappings.
local opts = { noremap = true, silent = true, buffer = bufnr}
-- local function keymap(mode, lhs, rhs) vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- local function keymap(mode, lhs, rhs) vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
require("legendary").keymaps{
{
@ -114,22 +114,22 @@ function M.on_attach(client, bufnr)
}
}
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- Conflicts with movement between panes
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
-- " auto-format
-- autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
@ -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

View File

@ -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

View File

@ -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
}

View 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
View File

@ -0,0 +1 @@
require("mason").setup()

View File

@ -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" },

View File

@ -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
View 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
}

View File

@ -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
})

View File

@ -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 {