From c7a88a07b9287db9c129914483f6b3ae1ab5404c Mon Sep 17 00:00:00 2001 From: awy Date: Fri, 14 Nov 2025 23:43:38 +0300 Subject: init --- .config/nvim/init.lua | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 .config/nvim/init.lua (limited to '.config/nvim/init.lua') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..51ebf0e --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,173 @@ +vim.o.number = true +vim.o.relativenumber = true +vim.o.signcolumn = "yes" +vim.o.wrap = false +vim.o.tabstop = 2 +vim.o.shiftwidth = 2 +vim.o.softtabstop = 2 +vim.o.expandtab = true +vim.o.swapfile = false +vim.g.mapleader = " " +vim.o.clipboard = "unnamedplus" +vim.o.undofile = true +vim.o.cursorline = true +vim.o.cursorlineopt = "number" +vim.o.title = true +vim.opt.shortmess:append "sI" + +-- packages +vim.pack.add({ + -- { src = "https://github.com/sainnhe/everforest" }, + { src = "https://github.com/ellisonleao/gruvbox.nvim" }, + -- { src = "https://github.com/rmehri01/onenord.nvim" }, + { src = "https://github.com/mason-org/mason.nvim", }, + { src = "https://github.com/nvim-lualine/lualine.nvim" }, + { src = "https://github.com/lewis6991/gitsigns.nvim" }, + { src = "https://github.com/cappyzawa/trim.nvim" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, + { src = "https://github.com/lukas-reineke/indent-blankline.nvim" }, + { src = "https://github.com/nvim-telescope/telescope.nvim" }, + { src = "https://github.com/nvim-telescope/telescope-ui-select.nvim" }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, + { src = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + { src = "https://github.com/hrsh7th/nvim-cmp" }, + { src = "https://github.com/L3MON4D3/LuaSnip" }, + { src = "https://github.com/saadparwaiz1/cmp_luasnip" }, + { src = "https://github.com/rafamadriz/friendly-snippets" }, + { src = "https://github.com/numToStr/Comment.nvim" }, +}) + +require("mason").setup() + +-- telescope +local telescope = require("telescope") +telescope.setup({ + defaults = { + preview = { treesitter = false }, + color_devicons = true, + sorting_strategy = "ascending", + borderchars = { + "─", -- top + "│", -- right + "─", -- bottom + "│", -- left + "┌", -- top-left + "┐", -- top-right + "┘", -- bottom-right + "└", -- bottom-left + }, + path_displays = { "smart" }, + layout_config = { + height = 100, + width = 400, + prompt_position = "top", + preview_cutoff = 40, + } + } +}) +telescope.load_extension("ui-select") +local builtin = require("telescope.builtin") + +-- binds +vim.keymap.set('n', 'lf', vim.lsp.buf.format) +vim.api.nvim_set_keymap('n', ',c', ':w! | !compiler "%:p"', { noremap = true, silent = true }) +vim.keymap.set({ "n" }, "f", builtin.find_files, { desc = "Telescope live grep" }) +vim.keymap.set({ "n" }, "g", builtin.live_grep, { desc = "Telescope live grep" }) + +-- lsp +vim.lsp.enable({ + "lua_ls", "clangd", "rust_analyzer", "bashls", + "html", "cssls", "jsonls", "helm_ls", "yamlls", + "docker_language_server" +}) + +vim.diagnostic.config({ + virtual_text = { + prefix = '', + spacing = 4, + }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '', + [vim.diagnostic.severity.WARN] = '', + }, + -- linehl = { + -- [vim.diagnostic.severity.ERROR] = 'ErrorMsg', + -- }, + -- numhl = { + -- [vim.diagnostic.severity.WARN] = 'WarningMsg', + -- }, + }, + underline = true, + update_in_insert = true, + severity_sort = true, +}) + +-- plugins +require('Comment').setup() +require('lualine').setup({}) +require("gitsigns").setup() +require("trim").setup({}) +require("nvim-treesitter.configs").setup({ + ensure_installed = { + "bash", + "lua", + "javascript", + "c", + "cpp", + "json", + "go", + "markdown", + "meson", + "make", + "cmake", + "python", + "rust", + "yaml", + "toml", + "ron", + "helm" + }, + highlight = { enable = true }, + indent = { enable = true }, +}) +require("ibl").setup({}) + +local cmp = require 'cmp' +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }) +}) + +vim.filetype.add({ + pattern = { + [".*/templates/.*%.yaml"] = "helm", + [".*/templates/.*%.yml"] = "helm", + }, +}) + +-- theme +-- vim.g.everforest_transparent_background = true +-- vim.cmd("colorscheme everforest") +-- vim.cmd("colorscheme onenord") +vim.cmd("colorscheme gruvbox") -- cgit v1.2.3