From e7b4be729612845c40866afa17f3c3e3a1d3a4ac Mon Sep 17 00:00:00 2001 From: 2ndbeam <2ndbeam@disroot.org> Date: Tue, 24 Feb 2026 11:55:27 +0300 Subject: [PATCH] Initial commit --- ftplugin/lua.vim | 2 ++ init.lua | 10 ++++++++++ lazy-lock.json | 15 +++++++++++++++ lua/config/lazy.lua | 31 +++++++++++++++++++++++++++++++ lua/config/lsp.lua | 13 +++++++++++++ lua/config/mappings.lua | 31 +++++++++++++++++++++++++++++++ lua/config/opts.lua | 10 ++++++++++ lua/lsp/lua_ls.lua | 1 + lua/lsp/rust_analyzer.lua | 1 + lua/plugins/cmp.lua | 33 +++++++++++++++++++++++++++++++++ lua/plugins/gdb.lua | 5 +++++ lua/plugins/lazydev.lua | 9 +++++++++ lua/plugins/lsp.lua | 16 ++++++++++++++++ lua/plugins/telescope.lua | 9 +++++++++ lua/plugins/theme.lua | 15 +++++++++++++++ lua/plugins/trouble.lua | 7 +++++++ lua/plugins/which.lua | 5 +++++ 17 files changed, 213 insertions(+) create mode 100644 ftplugin/lua.vim create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/lsp.lua create mode 100644 lua/config/mappings.lua create mode 100644 lua/config/opts.lua create mode 100644 lua/lsp/lua_ls.lua create mode 100644 lua/lsp/rust_analyzer.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/gdb.lua create mode 100644 lua/plugins/lazydev.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/theme.lua create mode 100644 lua/plugins/trouble.lua create mode 100644 lua/plugins/which.lua diff --git a/ftplugin/lua.vim b/ftplugin/lua.vim new file mode 100644 index 0000000..884dc4c --- /dev/null +++ b/ftplugin/lua.vim @@ -0,0 +1,2 @@ +setlocal tabstop=2 +setlocal shiftwidth=2 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..797f005 --- /dev/null +++ b/init.lua @@ -0,0 +1,10 @@ +require 'config.lazy' + +local mappings = require 'config.mappings' + +for mode, mode_tbl in pairs(mappings) do + for _, tbl in ipairs(mode_tbl) do + --vim.api.nvim_set_keymap(mode, tbl[1], tbl[2], tbl[3]) + vim.keymap.set(mode, tbl[1], tbl[2], tbl[3]) + end +end diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..f85033b --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,15 @@ +{ + "ansi-nvim": { "branch": "main", "commit": "8d0078f63d161de882bca21a505f84ee442fa194" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-gdb": { "branch": "master", "commit": "b644f07c54608cc913c1d9e14954f15dcb7331a9" }, + "nvim-lspconfig": { "branch": "master", "commit": "44acfe887d4056f704ccc4f17513ed41c9e2b2e6" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..4686daf --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,31 @@ +require 'config.opts' + +-- 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" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..d0bfa78 --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,13 @@ +-- Load lsp.name with required setup +local requires = { + 'rust_analyzer', + 'lua_ls', +} +local lsps = {} + +for _, lsp_name in ipairs(requires) do + local lsp = require('lsp.' .. lsp_name) + lsps[lsp_name] = lsp +end + +return lsps diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua new file mode 100644 index 0000000..4c9de2a --- /dev/null +++ b/lua/config/mappings.lua @@ -0,0 +1,31 @@ +local opts = { noremap = true, silent = true } + +---Make string like ':cmd' +---@param cmd string +---@return string +local function auto(cmd) + return string.format(':%s', cmd) +end + +---Make string like 'cmd' +---@param cmd string +---@return string +local function ld(cmd) + return string.format('%s', cmd) +end + +return { + n = { + { ld('ev'), auto('vsplit $MYVIMRC'), opts }, + { ld('sv'), auto('source $MYVIMRC'), opts }, + { ld('n'), auto('Telescope find_files'), opts }, + { ld('h'), auto('Telescope help_tags'), opts }, + { ld('/'), auto('Telescope live_grep'), opts }, + { ld('t'), auto('Trouble diagnostics'), opts }, + { ld('ds'), ':GdbStart rust-gdb -q target/debug/', opts }, + --{ ld('?'), function() require("which-key").show({ global = false }) end, opts }, + }, + i = { + { 'jk', '', opts }, + }, +} diff --git a/lua/config/opts.lua b/lua/config/opts.lua new file mode 100644 index 0000000..36383d3 --- /dev/null +++ b/lua/config/opts.lua @@ -0,0 +1,10 @@ +vim.o.number = true +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true +vim.o.smartindent = true +vim.o.cursorline = true +vim.o.keymap = 'russian-jcuken' +vim.o.iminsert = 0 +vim.o.imsearch = 0 +vim.g.mapleader = ' ' diff --git a/lua/lsp/lua_ls.lua b/lua/lsp/lua_ls.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/lsp/lua_ls.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/lsp/rust_analyzer.lua b/lua/lsp/rust_analyzer.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/lsp/rust_analyzer.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..fdcd7b1 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,33 @@ +return { + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + }, + opts = function() + local cmp = require 'cmp' + return { + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'lazydev', group_index = 0 } + }), + } + end, + } +} diff --git a/lua/plugins/gdb.lua b/lua/plugins/gdb.lua new file mode 100644 index 0000000..48bdc06 --- /dev/null +++ b/lua/plugins/gdb.lua @@ -0,0 +1,5 @@ +return { + { + "sakhnik/nvim-gdb", + } +} diff --git a/lua/plugins/lazydev.lua b/lua/plugins/lazydev.lua new file mode 100644 index 0000000..65232c8 --- /dev/null +++ b/lua/plugins/lazydev.lua @@ -0,0 +1,9 @@ +return { + { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = {}, + }, + } +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..99107ca --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,16 @@ +return { + { + 'neovim/nvim-lspconfig', + dependencies = { + "hrsh7th/cmp-nvim-lsp" + }, + config = function() + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lsps = require 'config.lsp' + for lsp, config in pairs(lsps) do + vim.lsp.enable(lsp) + vim.lsp.config(lsp, config) + end + end, + } +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..f02d593 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,9 @@ +return { + { + 'nvim-telescope/telescope.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + }, + } +} diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua new file mode 100644 index 0000000..25fc8af --- /dev/null +++ b/lua/plugins/theme.lua @@ -0,0 +1,15 @@ +return { + { + 'stevedylandev/ansi-nvim', + config = function() + vim.opt.termguicolors = false + vim.cmd [[ + colorscheme ansi + highlight Normal guibg=NONE ctermbg=NONE + highlight NonText guibg=NONE ctermbg=NONE + highlight EndOfBuffer guibg=NONE ctermbg=NONE + highlight CursorLine ctermbg=Black + ]] + end, + } +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..7bfaa01 --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,7 @@ +return { + { + 'folke/trouble.nvim', + opts = {}, + cmd = 'Trouble', + } +} diff --git a/lua/plugins/which.lua b/lua/plugins/which.lua new file mode 100644 index 0000000..2788a6f --- /dev/null +++ b/lua/plugins/which.lua @@ -0,0 +1,5 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = {}, +}