From e4a37a1252336e1fef361fdeca2b0c2535437ab3 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sun, 27 Aug 2023 19:26:35 +0530 Subject: config/nvim: refactor --- .config/nvim | 1 - .config/nvim/init.lua | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitmodules | 3 -- 3 files changed, 116 insertions(+), 4 deletions(-) delete mode 160000 .config/nvim create mode 100644 .config/nvim/init.lua diff --git a/.config/nvim b/.config/nvim deleted file mode 160000 index 2636bee..0000000 --- a/.config/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2636bee2880cda1a41f3f35751161357ebdb5d32 diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..5171b7b --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,116 @@ +-- [[ baic opts ]] +vim.g.mapleader = " " +vim.o.ignorecase = true +vim.o.smartcase = true +vim.wo.number = true +vim.wo.relativenumber = true +vim.o.clipboard = "unnamedplus" +vim.o.breakindent = true +vim.o.undofile = true +vim.o.mouse = false +vim.o.guicursor = false +vim.o.termguicolors = true +vim.wo.signcolumn = "yes" + +-- [[ lib ]] +mapnl = function(lhs, rhs, opts) + vim.keymap.set("n", "" .. lhs, rhs, opts) +end + +-- [[ keybindings ]] +mapnl("cc", function() + if vim.api.nvim_get_option_value("colorcolumn", {}) == "" then + vim.api.nvim_set_option_value("colorcolumn", "79", {}) + else + vim.api.nvim_set_option_value("colorcolumn", "", {}) + end +end) + +-- [[ package manager ]] +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +local lazylock = vim.fn.stdpath("data") .. "/lazy/lazy-lock.json" +if not vim.loop.fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + vim.print("downloading " .. lazyrepo) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + lazyrepo, + "--branch=stable", -- latest stable release + lazypath, + }) + vim.api.nvim_echo({}, false, {}) +end +vim.opt.rtp:prepend(lazypath) + +-- [[ plugin setup ]] +require("lazy").setup({ + "tpope/vim-fugitive", + "tpope/vim-sleuth", + { "numToStr/Comment.nvim", opts = {} }, + { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + options = { + component_separators = "|", + section_separators = "", + }, + }, + }, + + { + "navarasu/onedark.nvim", + priority = 1000, + opts = { transparent = true }, + config = function(_, opts) + require("onedark").setup(opts) + vim.cmd.colorscheme "onedark" + end, + }, + + { + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + on_attach = function(bufnr) + mapnl("gp", require("gitsigns").prev_hunk, { buffer = bufnr }) + mapnl("gn", require("gitsigns").next_hunk, { buffer = bufnr }) + mapnl("ph", require("gitsigns").preview_hunk, { buffer = bufnr }) + end, + }, + }, +}, { lockfile = lazylock }) + +-- [[ treesitter setup ]] +require("nvim-treesitter.configs").setup { + ensure_installed = { + "c", + "bash", + "nix", + "lua", + "markdown", + "regex", + }, + sync_install = false, + auto_install = false, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "i", + node_incremental = "i", + node_decremental = "d", + }, + } +} diff --git a/.gitmodules b/.gitmodules index 0ea1d9d..744e475 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule ".local/bin/sds"] path = .local/bin/sds url = https://git.sinanmohd.com/sds -[submodule ".config/nvim"] - path = .config/nvim - url = https://git.sinanmohd.com/nvim -- cgit v1.2.3