all repos

init.lua @ 7c6803e7d187d595e54acf00576c49264cfccc2d

my nvim config
15 files changed, 141 insertions(+), 225 deletions(-)
refactor: add lazyload for plugins
Author: Smirnov Olexander ss2316544@gmail.com
Committed at: 2022-04-29 12:27:10 +0300
Parent: c457df4
M init.lua

@@ -1,8 +1,9 @@

-require "impatient" +local ok, impatient = pcall(require, "impatient") +if ok then + impatient.enable_profile() +end require "core.options" -require "fk.plugin" +require "plugins" require "core.keymaps" require "core.autocmd" - -require("onenord").setup()
A lua/configs/autopairs.lua

@@ -0,0 +1,3 @@

+require("nvim-autopairs").setup { + check_ts = true, +}
M lua/core/keymaps.lua

@@ -1,8 +1,9 @@

-local map = require "core.utils".map +local map = require("core.utils").map -- general map("n", "<C-s>", "<cmd>write!<cr>") map("i", "jk", "<esc>") +map("n", "<leader>h", "<cmd>nohlsearch<cr>") --- buffers map("n", "<S-h>", "<cmd>bp!<cr>")

@@ -32,3 +33,18 @@ map("v", "K", ":move '<-2<CR>gv-gv")

map("v", "J", ":move '>+1<CR>gv-gv") map("n", "<A-j>", ":m .+1<CR>==") map("n", "<A-k>", ":m .-2<CR>==") + +-- plugins +map("n", "<leader>e", "<cmd>NvimTreeToggle<cr>") + +-- telescope +map("n", "<leader>f", "<cmd>Telescope find_files<cr>") +map("n", "<leader>b", "<cmd>Telescope buffers<cr>") +map("n", "<leader>sr", "<cmd>Telescope oldfiles<cr>") +map("n", "<leader>st", "<cmd>Telescope live_grep<cr>") + +-- git +map("n", "<leader>gg", "<cmd>Neogit<cr>") +map("n", "<leader>gs", "<cmd>lua require[[gitsigns]].stage_hunk()<cr>") +map("n", "<leader>gr", "<cmd>lua require[[gitsigns]].reset_hunk()<cr>") +map("n", "<leader>gp", "<cmd>lua require[[gitsigns]].preview_hunk()<cr>")
M lua/core/options.lua

@@ -1,5 +1,7 @@

local o, g = vim.opt, vim.g +vim.cmd [[colo onenord]] + -- use filetype.lua instead of filetype.vim g.did_load_filetypes = 1 g.do_filetype_lua = 1
M lua/core/utils.lua

@@ -11,4 +11,16 @@ end

vim.keymap.set(mode, from, to, { noremap = true, silent = true }) end, + + ---@param path string + ---@return string + get_config = function(path) + return string.format("require[[%s]]", path) + end, + + ---@param path string + ---@return string + get_setup = function(path) + return string.format("require[[%s]].setup()", path) + end, }
D

@@ -1,101 +0,0 @@

-require("packer").init { - profile = { enable = true }, - display = { - open_fn = function() - return require("packer.util").float { border = "" } - end, - }, -} - -return require("packer").startup(function(use) - local get_setup = function(path) - return string.format("require[[%s]].setup()", path) - end - - local get_config = function(path) - return string.format("require[[%s]]", path) - end - - use "wbthomason/packer.nvim" - use "nvim-lua/plenary.nvim" - use "lewis6991/impatient.nvim" - use "nathom/filetype.nvim" - use "rmehri01/onenord.nvim" -- theme - - use { "~/code/gopher.nvim", ft = "go" } - - use { "tpope/vim-surround", keys = { "c", "d", "y" } } - use { "windwp/nvim-autopairs", config = get_config "fk.plugin.autopairs" } - use { "numToStr/Comment.nvim", keys = { "gc" }, config = get_setup "Comment" } - use { "nvim-lualine/lualine.nvim", config = get_config "fk.plugin.statusline" } - use { "kyazdani42/nvim-web-devicons", module = "nvim-web-devicons" } - - -- git - use { "lewis6991/gitsigns.nvim", config = get_config "fk.plugin.gitsigns" } - use { - "TimUntersberger/neogit", - cmd = "Neogit", - config = get_config "fk.plugin.neogit", - } - - -- menus :D - use { - "folke/which-key.nvim", - config = get_config "fk.plugin.whichkey", - } - - use { - "kyazdani42/nvim-tree.lua", - cmd = "NvimTreeToggle", - config = get_config "fk.plugin.nvimtree", - } - - use { - "folke/trouble.nvim", - cmd = { "Trouble", "TroubleToggle" }, - config = get_setup "trouble", - } - - use { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", - module = "telescope", - config = get_config "fk.plugin.telescope", - } - - -- lsp - use { - "neovim/nvim-lspconfig", - config = get_setup "fk.lsp", - requires = { - "williamboman/nvim-lsp-installer", - "jose-elias-alvarez/null-ls.nvim", - { "folke/lua-dev.nvim", module = "lua-dev" }, - "j-hui/fidget.nvim", - }, - } - - -- completion - use { - "hrsh7th/nvim-cmp", - config = get_config "fk.plugin.cmp", - module = "cmp", - requires = { - { "hrsh7th/cmp-nvim-lsp", module = "cmp_nvim_lsp" }, - { "hrsh7th/cmp-buffer", after = "nvim-cmp" }, - { "hrsh7th/cmp-path", after = "nvim-cmp" }, - { "saadparwaiz1/cmp_luasnip", after = "nvim-cmp" }, - - "L3MON4D3/LuaSnip", - "rafamadriz/friendly-snippets", - }, - } - - -- treesitter - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - config = get_config "fk.plugin.treesitter", - requires = { "RRethy/nvim-treesitter-endwise" }, - } -end)
D

@@ -1,4 +0,0 @@

-local npairs = require "nvim-autopairs" - -npairs.setup { check_ts = true } -npairs.add_rules(require "nvim-autopairs.rules.endwise-lua")
M lua/configs/gitsigns.lualua/configs/gitsigns.lua

@@ -1,6 +1,5 @@

require("gitsigns").setup { max_file_length = 1000, - attach_to_untracked = true, current_line_blame = true, current_line_blame_opts = { virt_text_pos = "eol",
M lua/configs/neogit.lualua/configs/neogit.lua

@@ -1,7 +1,6 @@

require("neogit").setup { kind = "vsplit", signs = { - -- { CLOSED, OPENED } section = { "", "" }, item = { "", "" }, hunk = { "", "" },
M lua/configs/nvimtree.lualua/configs/nvimtree.lua

@@ -12,7 +12,7 @@ },

}, filters = { dotfiles = true, - custom = { ".git", "node_modules", "__pycache__", "vendor", "env", ".bin" }, + custom = { ".git", "node_modules", "__pycache__", "vendor" }, }, git = { enable = true, ignore = false }, view = {
M lua/configs/telescope.lualua/configs/telescope.lua

@@ -1,18 +1,10 @@

local actions = require "telescope.actions" -local action_layout = require "telescope.actions.layout" require("telescope").setup { defaults = { prompt_prefix = " ", selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", layout_config = { - width = 0.75, - preview_cutoff = 120, prompt_position = "top", horizontal = { mirror = false }, vertical = { mirror = false },

@@ -25,22 +17,15 @@ "vendor",

".git", ".bin", }, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - color_devicons = true, - set_env = { ["COLORTERM"] = "truecolor" }, mappings = { i = { ["<esc>"] = actions.close, ["<C-j>"] = actions.move_selection_next, ["<C-k>"] = actions.move_selection_previous, - ["<A-p>"] = action_layout.toggle_preview, }, n = { ["<C-j>"] = actions.move_selection_next, ["<C-k>"] = actions.move_selection_previous, - ["<A-p>"] = action_layout.toggle_preview, }, }, },

@@ -58,6 +43,5 @@ lsp_references = { theme = "ivy" },

lsp_implementations = { theme = "ivy" }, lsp_code_actions = { theme = "cursor" }, lsp_document_symbols = { theme = "ivy" }, - reloader = { theme = "cursor" }, }, }
D

@@ -1,96 +0,0 @@

-local wk = require "which-key" - -wk.setup { - plugins = { - marks = false, - registers = false, - spelling = { enabled = false, suggestions = 20 }, - presets = { - operators = true, - motions = true, - text_objects = true, - windows = true, - nav = true, - z = true, - g = true, - }, - }, - operators = { gc = "Comments" }, - hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, - popup_mappings = { scroll_down = "<c-d>", scroll_up = "<c-u>" }, - ignore_missing = true, - show_help = true, - key_labels = { ["<space>"] = "SPC", ["<cr>"] = "RET", ["<tab>"] = "TAB" }, - icons = { breadcrumb = "»", separator = "➜", group = "+" }, - window = { - border = "none", - position = "bottom", - margin = { 1, 0, 1, 0 }, - padding = { 2, 2, 2, 2 }, - winblend = 0, - }, - layout = { - height = { min = 4, max = 25 }, - width = { min = 20, max = 50 }, - spacing = 4, - align = "left", - }, -} - -local opts = { - mode = "n", - prefix = "<leader>", - buffer = nil, - silent = true, - noremap = true, - nowait = false, -} - -local mappings = { - f = { "<cmd>Telescope find_files<cr>", "Find file" }, - e = { "<cmd>NvimTreeToggle<cr>", "File explorer" }, - b = { "<cmd>Telescope buffers<cr>", "Find buffer" }, - w = { "<cmd>write!<cr>", "Save file" }, - q = { "<cmd>quit!<cr>", "Quit" }, - c = { "<cmd>bdelete!<cr>", "Close buffer" }, - h = { "<cmd>nohlsearch<cr>", "No search hl" }, - n = { "<cmd>e! /tmp/note.md<cr>", "Open note" }, - s = { - name = "Search", - b = { "<cmd>Telescope git_branches<cr>", "Git branches" }, - g = { "<cmd>Telescope git_status<cr>", "Git status" }, - r = { "<cmd>Telescope oldfiles<cr>", "Find oldfile" }, - t = { "<cmd>Telescope live_grep<cr>", "Live grep" }, - }, - l = { - name = "Lsp", - a = { "<cmd>Telescope lsp_code_actions<cr>", "Code actions" }, - q = { "<cmd>TroubleToggle<cr>", "Diagnostics menu" }, - r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" }, - f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" }, - i = { "<cmd>LspInfo<cr>", "Lsp info" }, - R = { "<cmd>LspRestart<cr>", "Restart lsp server" }, - s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, - l = { "<cmd>lua vim.lsp.codelens.run()<cr>", "CodeLens action" }, - j = { "<cmd>lua vim.diagnostic.goto_next()<cr>", "Next diagnostic" }, - k = { "<cmd>lua vim.diagnostic.goto_prev()<cr>", "Prev diagnostic" }, - }, - t = { - name = "Tabs", - l = { "<cmd>tabnext<cr>", "Next tab" }, - h = { "<cmd>tabprev<cr>", "Prev tab" }, - N = { "<cmd>tabnew<cr>", "New tab" }, - }, - g = { - name = "Git", - g = { "<cmd>Neogit<cr>", "Neogit" }, - s = { "<cmd>lua require[[gitsigns]].stage_hunk()<cr>", "Stage hunk" }, - r = { "<cmd>lua require[[gitsigns]].reset_hunk()<cr>", "Reset hunk" }, - p = { "<cmd>lua require[[gitsigns]].preview_hunk()<cr>", "Preview hunk" }, - b = { "<cmd>lua require[[gitsigns]].blame_line {}<cr>", "Blame line" }, - R = { "<cmd>lua require[[gitsigns]].reset_buffer()<cr>", "Reset buffer" }, - S = { "<cmd>lua require[[gitsigns]].stage_buffer()<cr>", "Stage buffer" }, - }, -} - -wk.register(mappings, opts)
A lua/plugins.lua

@@ -0,0 +1,101 @@

+local packer = require "packer" +local u = require "core.utils" + +packer.init { + profile = { enable = true }, + display = { + open_fn = function() + return require("packer.util").float { border = "" } + end, + }, +} + +return packer.startup(function(use) + use "wbthomason/packer.nvim" + use "nvim-lua/plenary.nvim" + use "lewis6991/impatient.nvim" + use "nathom/filetype.nvim" + use "rmehri01/onenord.nvim" -- theme + + use { "tpope/vim-surround", keys = { "c", "d", "y" } } + use { "kyazdani42/nvim-web-devicons", module = "nvim-web-devicons" } + + use { + "numToStr/Comment.nvim", + keys = "gc", + event = "BufRead", + config = u.get_setup "Comment", + } + + use { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = u.get_config "configs.autopairs", + } + + use { + "lewis6991/gitsigns.nvim", + event = "BufRead", + config = u.get_config "configs.gitsigns", + } + + use { + "TimUntersberger/neogit", + cmd = "Neogit", + config = u.get_config "configs.neogit", + } + + use { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + module = "telescope", + config = u.get_config "configs.telescope", + } + + use { + "nvim-treesitter/nvim-treesitter", + event = { "BufRead", "BufNewFile" }, + config = u.get_config "configs.treesitter", + requires = { "RRethy/nvim-treesitter-endwise" }, + } + + use { + "nvim-lualine/lualine.nvim", + after = "onenord.nvim", + config = u.get_config "configs.statusline", + } + + use { + "kyazdani42/nvim-tree.lua", + cmd = "NvimTreeToggle", + config = u.get_config "configs.nvimtree", + } + + --[[ + use { + "neovim/nvim-lspconfig", + config = get_setup "fk.lsp", + requires = { + "williamboman/nvim-lsp-installer", + "jose-elias-alvarez/null-ls.nvim", + { "folke/lua-dev.nvim", module = "lua-dev" }, + "j-hui/fidget.nvim", + }, + } + + -- completion + use { + "hrsh7th/nvim-cmp", + config = get_config "fk.plugin.cmp", + module = "cmp", + requires = { + { "hrsh7th/cmp-nvim-lsp", module = "cmp_nvim_lsp" }, + { "hrsh7th/cmp-buffer", after = "nvim-cmp" }, + { "hrsh7th/cmp-path", after = "nvim-cmp" }, + { "saadparwaiz1/cmp_luasnip", after = "nvim-cmp" }, + + "L3MON4D3/LuaSnip", + "rafamadriz/friendly-snippets", + }, + }]] +end)