First commit

This commit is contained in:
Egor 2024-10-21 11:08:26 +03:00
commit 0731db0833
24 changed files with 469 additions and 0 deletions

7
.config/nvim/init.lua Normal file
View file

@ -0,0 +1,7 @@
require('config.options')
require('config.lazy')
require('config.keymaps')
require('config.langmap')
require('langmapper').automapping({ global = true, buffer = true })

View file

@ -0,0 +1,33 @@
{
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"go.nvim": { "branch": "master", "commit": "8389adb56ab124b75d858df5f87b741eaca7b8b3" },
"guihua.lua": { "branch": "master", "commit": "225db770e36aae6a1e9e3a65578095c8eb4038d3" },
"langmapper.nvim": { "branch": "main", "commit": "62cc28b4ebc5f47e6d4a6b5dd478c93b812f7187" },
"lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"nvim": { "branch": "main", "commit": "4fd72a9ab64b393c2c22b168508fd244877fec96" },
"nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" },
"nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-tree.lua": { "branch": "master", "commit": "ea55ef12036897fdc4476b115a395d2a34965c82" },
"nvim-treesitter": { "branch": "master", "commit": "2d8f0f37c4056022b6643cbe8671319881f8b369" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
"sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"vim-be-good": { "branch": "master", "commit": "4fa57b7957715c91326fcead58c1fa898b9b3625" }
}

View file

@ -0,0 +1,9 @@
vim.keymap.set('n', '<c-w>v', ':vnew<cr>')
vim.keymap.set('n', '<c-b>', ':bn<cr>')
vim.keymap.set('n', '<s-b>', ':bp<cr>')
vim.keymap.set('n', '<c-d>', ':bd<cr>:bn<cr>')
vim.keymap.set('n', '<c-j>', '<c-w><Down>')
vim.keymap.set('n', '<c-k>', '<c-w><Up>')
vim.keymap.set('n', '<c-h>', '<c-w><Left>')
vim.keymap.set('n', '<c-l>', '<c-w><Right>')
vim.keymap.set('n', '<leader><cr>', ':lua vim.lsp.buf.code_action()<cr>')

View file

@ -0,0 +1,15 @@
local function escape(str)
local escape_chars = [[;,."|\]]
return vim.fn.escape(str, escape_chars)
end
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

@ -0,0 +1,17 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- s also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require('lazy').setup('plugins')

View file

@ -0,0 +1,25 @@
vim.g.mapleader = ' '
vim.opt.termguicolors = true
vim.opt.autoindent = true
vim.opt.clipboard = 'unnamedplus'
vim.opt.mouse = 'a'
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.showmode = false
vim.opt.incsearch = true
vim.opt.hlsearch = false
vim.opt.ignorecase = true
vim.opt.smartcase = true

View file

@ -0,0 +1,6 @@
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
config = true,
}

View file

@ -0,0 +1,21 @@
return {
'akinsho/bufferline.nvim',
version = '*',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function ()
require('bufferline').setup({
options = {
diagnostics = 'nvim_lsp',
separator_style = 'slant',
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
separator = true
}
}
}
})
end
}

View file

@ -0,0 +1,15 @@
return {
'stevearc/conform.nvim',
opts = {},
config = function ()
require('conform').setup({
formatters_by_ft = {
cpp = { 'clang-format' }
},
format_on_save = {
timeout_ms = 500,
lsp_format = 'fallback'
}
})
end
}

View file

@ -0,0 +1,22 @@
return {
'ray-x/go.nvim',
dependencies = {
'ray-x/guihua.lua',
'neovim/nvim-lspconfig',
'nvim-treesitter/nvim-treesitter',
},
config = function()
require('go').setup()
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimports()
end,
group = format_sync_grp,
})
end,
event = {'CmdlineEnter'},
ft = {'go', 'gomod'},
build = ':lua require("go.install").update_all_sync()'
}

View file

@ -0,0 +1,8 @@
return {
{
'williamboman/mason.nvim',
config = true
},
'ThePrimeagen/vim-be-good',
}

View file

@ -0,0 +1,8 @@
return {
'Wansmer/langmapper.nvim',
lazy = false,
priority = 1, -- High priority is needed if you will use `autoremap()`
config = function()
require('langmapper').setup()
end,
}

View file

@ -0,0 +1,98 @@
return {
{
'williamboman/mason-lspconfig.nvim',
opts = {
ensure_installed = { 'lua_ls', 'gopls', 'rust_analyzer', 'pylsp' }
}
},
{
'L3MON4D3/LuaSnip',
version = 'v2.*',
build = 'make install_jsregexp',
dependencies = {
'rafamadriz/friendly-snippets'
},
config = function()
local vscode_loader = require('luasnip.loaders.from_vscode')
vscode_loader.lazy_load()
vscode_loader.lazy_load({ paths = { './snippets' } })
local ls = require('luasnip')
vim.keymap.set({ "i" }, "<C-K>", function() ls.expand() end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-L>", function() ls.jump(1) end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-J>", function() ls.jump(-1) end, { silent = true })
end
},
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp',
'saadparwaiz1/cmp_luasnip'
},
config = function()
local has_words_before = function()
unpack = unpack or table.unpack
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
local cmp = require('cmp')
local luasnip = require('luasnip')
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = 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" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
})
})
end
},
{
'neovim/nvim-lspconfig',
config = function()
local lspconfig = require('lspconfig')
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
lspconfig.lua_ls.setup({ capabilities = lsp_capabilities })
lspconfig.rust_analyzer.setup({ capabilities = lsp_capabilities })
lspconfig.gopls.setup({ capabilities = lsp_capabilities })
lspconfig.typst_lsp.setup({ capabilities = lsp_capabilities })
lspconfig.clangd.setup({ capabilities = lsp_capabilities })
lspconfig.cmake.setup({ capabilities = lsp_capabilities })
end
},
}

View file

@ -0,0 +1,7 @@
return {
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = true
}
}

View file

@ -0,0 +1,9 @@
return {
'iamcco/markdown-preview.nvim',
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
build = 'cd app && yarn install',
init = function ()
vim.g.mkdp_filetypes = { 'markdown' }
end,
ft = { 'markdown' }
}

View file

@ -0,0 +1,11 @@
return {
'AckslD/nvim-neoclip.lua',
dependencies = {
{ 'kkharji/sqlite.lua', module = 'sqlite' },
{ 'nvim-telescope/telescope.nvim' }
},
config = function ()
require('neoclip').setup()
vim.keymap.set('n', '<leader>v', ':Telescope neoclip plus<cr>')
end
}

View file

@ -0,0 +1,6 @@
return {
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = true
}

View file

@ -0,0 +1,18 @@
return {
'nvim-telescope/telescope.nvim', tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function ()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>lr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>ld', builtin.lsp_definitions, {})
vim.keymap.set('n', '<leader>li', builtin.lsp_implementations, {})
vim.keymap.set('n', '<leader>gc', builtin.git_commits, {})
vim.keymap.set('n', '<leader>gb', builtin.git_branches, {})
vim.keymap.set('n', '<leader>gs', builtin.git_status, {})
vim.keymap.set('n', '<leader>bb', builtin.builtin, {})
end
}

View file

@ -0,0 +1,17 @@
return {
'catppuccin/nvim',
lazy = false,
priority = 1000,
config = function()
require('catppuccin').setup({
flavour = 'mocha',
integrations = {
cmp = true,
nvimtree = true,
treesitter = true
}
})
vim.cmd[[colorscheme catppuccin]]
end
}

View file

@ -0,0 +1,19 @@
return {
'nvim-tree/nvim-tree.lua',
dependencies = {
'nvim-tree/nvim-web-devicons'
},
config = function ()
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.keymap.set('n', '<leader>e', ':NvimTreeToggle<cr>')
require('nvim-tree').setup({
filters = {
dotfiles = true
}
})
vim.api.nvim_create_autocmd({"QuitPre"}, {
callback = function() vim.cmd("NvimTreeClose") end,
})
end
}

View file

@ -0,0 +1,14 @@
return {
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function ()
local configs = require('nvim-treesitter.configs')
configs.setup({
ensure_installed = { 'c', 'lua', 'vim', 'vimdoc', 'query' },
auto_install = true,
highlight = { enable = true },
indent = { enable = true }
})
end
}

View file

@ -0,0 +1,37 @@
return {
"folke/trouble.nvim",
opts = {},
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
}

View file

@ -0,0 +1,13 @@
{
"name": "my-snippets",
"contributes": {
"snippets": [
{
"language": [
"rust"
],
"path": "./rust.json"
}
]
}
}

View file

@ -0,0 +1,34 @@
{
"leetcode": {
"prefix": "leetcode",
"body": [
"pub struct Solution;",
"impl Solution {",
" pub fn ${1:name}(${2:arg}: ${3:Type}) -> ${4:RetType} {",
" ${5:todo!();}",
" }",
"}",
"",
"#[cfg(test)]",
"mod tests {",
" use super::Solution;",
"",
" #[test]",
" fn test1() {",
" ${6:todo!();}",
" }",
"",
" #[test]",
" fn test2() {",
" ${7:todo!();}",
" }",
"",
" #[test]",
" fn test3() {",
" ${8:todo!();}",
" }",
"}"
],
"description": "leetcode Solution snippet"
}
}