Last manual config (for now).

This commit is contained in:
Arthur Khachaturov 2023-11-30 15:56:13 +03:00
parent 9081c45880
commit da0b0bc5e9
9 changed files with 109 additions and 35 deletions

View file

@ -1,3 +1,4 @@
require("core")
require("plugins")
require("lsp")
require("mappings")

View file

@ -1 +0,0 @@
return { "vim-airline/vim-airline" }

View file

@ -1,8 +0,0 @@
return {
'Wansmer/langmapper.nvim',
lazy = false,
priority = 1,
config = {
hack_keymap = true,
}
}

View file

@ -0,0 +1,11 @@
return {
"itchyny/lightline.vim",
config = function()
vim.g.lightline = {
colorscheme = "one",
enable = {
tabline = 0
}
}
end
}

View file

@ -1,4 +0,0 @@
return {
"wakatime/vim-wakatime",
lazy = false,
}

View file

@ -17,17 +17,21 @@ vim.opt.syntax = on
-- Enable undo after closing vim
vim.opt.undofile = true
-- Make vim work with russian layout
local function escape(str)
local escape_chars = [[;,."|\]]
return vim.fn.escape(str, escape_chars)
-- vim.g.lightline = { colorscheme = "one" }
-- Autostart nvim-tree
local function open_nvim_tree(data)
local real_file = vim.fn.filereadable(data.file) == 1
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
local directory = vim.fn.isdirectory(data.file) == 1
if real_file or no_name then
require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, })
elseif directory then
vim.cmd.enew()
vim.cmd.cd(data.file)
require("nvim-tree.api").tree.open()
end
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
local en = [[`qwertyuiop[]asdfghjkl;'zxcvbnm]] local ru = [[ёйцукенгшщзхъфывапролджэячсмить]]
local en_shift = [[~QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>]]
local ru_shift = [[ËЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ]]
vim.opt.langmap = vim.fn.join({
escape(ru_shift) .. ';' .. escape(en_shift),
escape(ru) .. ';' .. escape(en),
}, ',')

View file

@ -1,9 +1,3 @@
-- require("utils").load_servers{
-- require("configs.lsp.pylsp"),
-- require("configs.lsp.clangd"),
-- require("configs.lsp.bash"),
-- }
--
local lspconfig = require("lspconfig")
local custom_attach = function(client, bufnr)

View file

@ -0,0 +1,78 @@
local map = vim.keymap.set
-- Remap leader
vim.g.mapleader = " "
map('n', '<Space>', '<Nop>')
-- Buffer movements
map("n", "<A-h>", ":bp<CR>")
map("n", "<A-l>", ":bn<CR>")
-- Make use of Shift+hjkl
map("n", "H", "^")
map("n", "L", "$")
map("n", "<A-j>", "}")
map("n", "<A-k>", "{")
-- Leader remap
map("n", "<Leader>w", ":write<CR>")
map("n", "<Leader>e", ":NvimTreeFocus<CR>")
-- Split movements
map("n", "<Leader>h", "<C-w>h")
map("n", "<Leader>j", "<C-w>j")
map("n", "<Leader>k", "<C-w>k")
map("n", "<Leader>l", "<C-w>l")
-- Remap comments
map("n", "<C-_>", require("Comment.api").toggle.linewise.current)
map("i", "<C-_>", require("Comment.api").toggle.linewise.current)
map("x", "<C-_>", function() -- some evil trickery with comment plugin
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<ESC>', true, false, true), 'nx', false)
require("Comment.api").toggle.linewise(vim.fn.visualmode())
end
)
-- Close buffer and nvim
local close_buffer_and_nvimtree = function()
local try_quit = function(command)
local success, errorMsg = pcall(vim.api.nvim_command, command)
if not success then
print("Failed to quit: " .. errorMsg)
end
end
local tree = require("nvim-tree.api").tree
local buffer_count = #vim.fn.filter(vim.fn.range(1, vim.fn.bufnr '$'), 'buflisted(v:val)')
if buffer_count == 0 then
try_quit("quit")
-- elseif buffer_count == 1 then
-- vim.cmd("e .")
-- try_quit("bd")
-- vim.cmd("NvimTreeClose")
else
tree.toggle({ focus = false })
try_quit("bd")
tree.toggle({ focus = false })
end
-- if buffer_count == 1 and #vim.api.nvim_list_wins() == 1 then
-- try_quit("quit")
-- end
end
-- Leader remapping
map("n", "<Leader>q", function() close_buffer_and_nvimtree() end)
map("n", "<Leader>Q", ":%bd | quit<CR>")
map("n", "<Leader><C-Q>", ":%bd! | quit!<CR>")
map("n", "<Leader><C-Q>", ":%bd! | quit!<CR>")
map("v", "<Leader>y", '"+y')
map("n", "<Leader>y", '"+yy')
map({ "n", "v" }, "<Leader>p", '"+p')
map({ "n", "v" }, "<Leader>P", '"+P')
-- Toggle tree
map("n", "<C-b>", function() require("nvim-tree.api").tree.toggle({ focus=false }) end)

View file

@ -3,12 +3,11 @@ require("utils").init_lazy()
require("lazy").setup{
require("configs.plugins.bufferline"),
require("configs.plugins.comment"),
require("configs.plugins.devicons"),
require("configs.plugins.lastplace"),
require("configs.plugins.lightline"),
require("configs.plugins.lspconfig"),
require("configs.plugins.nvim-tree"),
require("configs.plugins.onedark"),
require("configs.plugins.airline"),
require("configs.plugins.langmapper"),
require("configs.plugins.devicons"),
require("configs.plugins.treesitter"),
require("configs.plugins.lspconfig"),
}