diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..6c4a5a9 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1 @@ +require("kamu") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..2d2f795 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,18 @@ +{ + "LuaSnip": { "branch": "master", "commit": "cdbf6f41381e5ee4810b4b09284b603d8f18365d" }, + "catppuccin": { "branch": "main", "commit": "fc537040147f0374a22b88142a20eb6781141f0b" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "lazy.nvim": { "branch": "main", "commit": "41d3b2a9dbf03774a2c92c376d8371dcca9710a9" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "96f29a47fe48254cb3a826f6d7e90a108dae502d" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ddefe5ab051e7ca6a7b374754f0920c44668b54f" }, + "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-highlight-colors": { "branch": "main", "commit": "231547093a788b925b8fc36351ad422701c3a8c8" }, + "nvim-lspconfig": { "branch": "master", "commit": "2b361e043810d5587d9af0787f8ce40da92ec5e9" }, + "nvim-tree.lua": { "branch": "master", "commit": "53b0bcaadaffb505acff230578b56a86ec1ab38a" }, + "nvim-treesitter": { "branch": "master", "commit": "dfd4fb330f75595813e2a2f83000580a36dd10ff" }, + "nvim-web-devicons": { "branch": "master", "commit": "a1e6268779411048a87f767a27380089362a0ce2" }, + "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, + "telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" } +} \ No newline at end of file diff --git a/.config/nvim/lua/kamu/init.lua b/.config/nvim/lua/kamu/init.lua new file mode 100644 index 0000000..0f859df --- /dev/null +++ b/.config/nvim/lua/kamu/init.lua @@ -0,0 +1,7 @@ +vim.g.mapleader = ' ' + +require("kamu.options") +--require("kamu.commands") +require("kamu.lazy") +require("kamu.keymaps") + diff --git a/.config/nvim/lua/kamu/keymaps.lua b/.config/nvim/lua/kamu/keymaps.lua new file mode 100644 index 0000000..0d2fc18 --- /dev/null +++ b/.config/nvim/lua/kamu/keymaps.lua @@ -0,0 +1,99 @@ + + +-- n, v, i, t = mode names + +local M = {} + +M.general = { + i = { + -- go to beginning and end + [""] = { "^i", "Beginning of line" }, + [""] = { "", "End of line" }, + + -- navigate within insert mode + [""] = { "", "Move left" }, + [""] = { "", "Move right" }, + [""] = { "", "Move down" }, + [""] = { "", "Move up" }, + }, + + n = { + [""] = { ":noh ", "Clear highlights" }, + -- switch between windows + [""] = { "h", "Window left" }, + [""] = { "l", "Window right" }, + [""] = { "j", "Window down" }, + [""] = { "k", "Window up" }, + + -- save + [""] = { " w ", "Save file" }, + + -- Copy all + [""] = { " %y+ ", "Copy whole file" }, + + -- line numbers + ["n"] = { " set nu! ", "Toggle line number" }, + ["rn"] = { " set rnu! ", "Toggle relative number" }, + + -- Allow moving the cursor through wrapped lines with j, k, and + -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ + -- empty mode is same as using :map + -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + + -- new buffer + ["b"] = { " enew ", "New buffer" }, + ["ch"] = { " NvCheatsheet ", "Mapping cheatsheet" }, + + ["fm"] = { + function() + vim.lsp.buf.format { async = true } + end, + "LSP formatting", + }, + }, + + t = { + [""] = { vim.api.nvim_replace_termcodes("", true, true, true), "Escape terminal mode" }, + }, + + v = { + [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + ["<"] = { ""] = { ">gv", "Indent line" }, + }, + + x = { + ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + -- Don't copy the replaced text after pasting in visual mode + -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste + ["p"] = { 'p:let @+=@0:let @"=@0', "Dont copy replaced text", opts = { silent = true } }, + }, +} + + +M.comment = { + plugin = true, + + -- toggle comment in both modes + n = { + ["/"] = { + function() + require("Comment.api").toggle.linewise.current() + end, + "Toggle comment", + }, + }, + + v = { + ["/"] = { + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "Toggle comment", + }, + }, +} diff --git a/.config/nvim/lua/kamu/lazy.lua b/.config/nvim/lua/kamu/lazy.lua new file mode 100644 index 0000000..b1a965c --- /dev/null +++ b/.config/nvim/lua/kamu/lazy.lua @@ -0,0 +1,16 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +local opts = {} + +require("lazy").setup("kamu.plugins", opts) diff --git a/.config/nvim/lua/kamu/options.lua b/.config/nvim/lua/kamu/options.lua new file mode 100644 index 0000000..1626d6d --- /dev/null +++ b/.config/nvim/lua/kamu/options.lua @@ -0,0 +1,39 @@ +local options = { + autoindent = true, + smartindent = true, + tabstop = 2, + shiftwidth = 2, + expandtab = true, + + number = true, + relativenumber = true, + numberwidth = 4, + + swapfile = false, + backup = false, + undodir = os.getenv("HOME") .. "/.vim/undodir", + undofile = true, + + hlsearch = false, + incsearch = true, + + showtabline = 0, + + termguicolors = true, + + signcolumn = "yes", + wrap = false, + fileencoding = "utf-8", + + scrolloff = 8, + mouse = "a", + + updatetime = 50, + +-- guicursor = "a:block" +} + +for option, value in pairs(options) do + vim.opt[option] = value +end + diff --git a/.config/nvim/lua/kamu/plugins/colors.lua b/.config/nvim/lua/kamu/plugins/colors.lua new file mode 100644 index 0000000..4779980 --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/colors.lua @@ -0,0 +1,100 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + require("catppuccin").setup({ + flavour = "mocha", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = true, -- disables setting the background color. + show_end_of_buffer = false, -- shows the '~' characters after the end of buffers + term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = false, -- dims the background color of inactive window + shade = "dark", + percentage = 0.15, -- percentage of the shade to apply to the inactive window + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + no_underline = false, -- Force no underline + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + conditionals = { "italic" }, + loops = {"italic"}, + functions = {"italic"}, + keywords = {"bold"}, + strings = {}, + variables = {}, + numbers = {"italic"}, + booleans = {"italic"}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = { + all = { + text = "#ffffff", + }, + mocha = { + base = "#000000", + mantle = "#242424", + crust = "#474747", + blue = "#0f63bd", + surface1 = "#011f2a", + --blue = "#0ca8fb", --accent color +-- rosewater = "#f5e0dc", +-- flamingo = "#f2cdcd", +-- pink = "#f5c2e7", +-- mauve = "#cba6f7", +-- red = "#f38ba8", +-- maroon = "#eba0ac", +-- peach = "#fab387", +-- yellow = "#f9e2af", +-- green = "#a6e3a1", +-- teal = "#94e2d5", +-- sky = "#89dceb", +-- sapphire = "#74c7ec", +-- blue = "#89b4fa", +-- lavender = "#b4befe", +-- text = "#cdd6f4", +-- subtext1 = "#bac2de", +-- subtext0 = "#a6adc8", +-- overlay2 = "#9399b2", +-- overlay1 = "#7f849c", +-- overlay0 = "#6c7086", +-- surface2 = "#585b70", +-- surface1 = "#45475a", +-- surface0 = "#313244", +-- base = "#1e1e2e", +-- mantle = "#181825", +-- crust = "#11111b", + } + }, + custom_highlights = function(colors) + return { + Comment = { fg = "#89AEB1" } + } + end, + integrations = { + cmp = false, + gitsigns = false, + nvimtree = false, + telescope = { + enabled = true, + }, + treesitter = true, + notify = false, + mini = false, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, + }) + vim.cmd.colorscheme "catppuccin" + + vim.api.nvim_set_hl(0, 'LineNrAbove', { fg='#CACACA', }) + vim.api.nvim_set_hl(0, 'LineNrBelow', { fg='#CACACA', }) + vim.api.nvim_set_hl(0, 'LineNr', { fg = "#0ca8fb", bold=true } ) + end, +} diff --git a/.config/nvim/lua/kamu/plugins/highlight-colors.lua b/.config/nvim/lua/kamu/plugins/highlight-colors.lua new file mode 100644 index 0000000..5cd83b6 --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/highlight-colors.lua @@ -0,0 +1,8 @@ +return { + 'brenoprata10/nvim-highlight-colors', + config = function() + require('nvim-highlight-colors').setup { + render = 'background' + } + end, +} diff --git a/.config/nvim/lua/kamu/plugins/lsp.lua b/.config/nvim/lua/kamu/plugins/lsp.lua new file mode 100644 index 0000000..695f5b7 --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/lsp.lua @@ -0,0 +1,61 @@ +return { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'neovim/nvim-lspconfig', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/nvim-cmp', + 'L3MON4D3/LuaSnip' + }, + config = function() + local lsp_zero = require('lsp-zero') + + lsp_zero.on_attach(function(client, bufnr) + local opts = {buffer = bufnr, remap = false} + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) + end) + + require('mason').setup({}) + require('mason-lspconfig').setup({ + ensure_installed = {'rust_analyzer'}, + handlers = { + lsp_zero.default_setup, + lua_ls = function() + local lua_opts = lsp_zero.nvim_lua_ls() + require('lspconfig').lua_ls.setup(lua_opts) + end, + } + }) + + local cmp = require('cmp') + local cmp_select = {behavior = cmp.SelectBehavior.Select} + + cmp.setup({ + sources = { + {name = 'path'}, + {name = 'nvim_lsp'}, + {name = 'nvim_lua'}, + }, + formatting = lsp_zero.cmp_format(), + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), + }), + }) + end, +} + diff --git a/.config/nvim/lua/kamu/plugins/lualine.lua b/.config/nvim/lua/kamu/plugins/lualine.lua new file mode 100644 index 0000000..917abf9 --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/lualine.lua @@ -0,0 +1,167 @@ +local palette = require("catppuccin.palettes.init").get_palette() + +local mode_map = { + ['n'] = 'NORMAL', + ['no'] = 'O-PENDING', + ['nov'] = 'O-PENDING', + ['noV'] = 'O-PENDING', + ['no\22'] = 'O-PENDING', + ['niI'] = 'NORMAL', + ['niR'] = 'NORMAL', + ['niV'] = 'NORMAL', + ['nt'] = 'NORMAL', + ['ntT'] = 'NORMAL', + ['v'] = 'VISUAL', + ['vs'] = 'VISUAL', + ['V'] = 'V-LINE', + ['Vs'] = 'V-LINE', + ['\22'] = 'V-BLOCK', + ['\22s'] = 'V-BLOCK', + ['s'] = 'SELECT', + ['S'] = 'S-LINE', + ['\19'] = 'S-BLOCK', + ['i'] = 'INSERT', + ['ic'] = 'INSERT', + ['ix'] = 'INSERT', + ['R'] = 'REPLACE', + ['Rc'] = 'REPLACE', + ['Rx'] = 'REPLACE', + ['Rv'] = 'V-REPLACE', + ['Rvc'] = 'V-REPLACE', + ['Rvx'] = 'V-REPLACE', + ['c'] = 'COMMAND', + ['cv'] = 'EX', + ['ce'] = 'EX', + ['r'] = 'REPLACE', + ['rm'] = 'MORE', + ['r?'] = 'CONFIRM', + ['!'] = 'SHELL', + ['t'] = 'TERMINAL', +} + +local mode2themeMap = { + ['NORMAL'] = 'normal', + ['VISUAL'] = 'visual', + ['V-LINE'] = 'visual', + ['V-BLOCK'] = 'visual', + ['INSERT'] = 'insert', + ['REPLACE'] = 'replace', + ['COMMAND'] = 'command', + ['TERMINAL'] = 'terminal', +} + +function getModeColor(section, type) + local theme = require("catppuccin.utils.lualine")("mocha") + local mode = vim.api.nvim_get_mode().mode + if mode == nil then + return theme['normal'][section][type] + end + + local modeColors = theme[mode2themeMap[mode_map[mode]]] + if modeColors == nil then modeColors = theme['inactive'] end + + return modeColors[section][type] +end + +return { + 'nvim-lualine/lualine.nvim', + dependencies = {'kyazdani42/nvim-web-devicons', opt = true }, + config = function() + require('lualine').setup { + options = { + theme = 'catppuccin', + --fmt = string.lower, + icons_enabled = true, + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = false, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = { + { + 'mode', + color = function() + if vim.fn.mode() == "n" then return { fg = palette.text, gui = "bold" } end + return { fg = "#000000", gui = "bold" } + end, + -- fmt = function(str) return str:sub(1,1) end, + }}, + lualine_b = { + { + 'branch', + color = { fg = "#FFF"}, + icon = {'', color = function() return { fg = getModeColor('a','bg') } end }, + }, + { + 'diff', + diff_color = { + -- custom color for each section of the component in format + -- {fg = '#rrggbb', bg= '#rrggbb', gui='style'} + -- or highlight group + added = nil, -- {fg = '#rrggbb', bg= '#rrggbb', gui='style'}, -- changes diff's added color + modified = { fg = "#FFFFFF" }, -- changes diff's modified color + removed = nil, -- changes diff's removed color + }, + }, + -- 'diagnostics' + }, + lualine_c = {{ + 'filename', + on_click = function(nc, mb, mods) + local tb = require("telescope.builtin") + if mb == "l" then + --vim.print(mods) + local mod = mods:gsub("%s+", "") + if mod == "c" then tb.find_files(); return end + if mod == "a" then tb.buffers(); return end + end + --require("telescope.builtin").find_files() + end, + }}, + lualine_x = { + -- { + -- function() + -- return getModeColor('a','bg') + -- end + -- }, + 'encoding', 'fileformat', 'filetype'}, + lualine_y = { + { + 'progress', + color = { fg = "#FFFFFF"}, + } + }, + lualine_z = {{ + 'location', + color = function(section) + if vim.fn.mode() == "n" then return { fg = palette.text } end + return { fg = "#000000", } + end, + }} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} + } + end, +} diff --git a/.config/nvim/lua/kamu/plugins/telescope.lua b/.config/nvim/lua/kamu/plugins/telescope.lua new file mode 100644 index 0000000..44c3422 --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/telescope.lua @@ -0,0 +1,13 @@ +return { + "nvim-telescope/telescope.nvim", + tag = '0.1.3', + dependencies = {'nvim-lua/plenary.nvim'}, + config = function() + require("telescope").setup() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fg', builtin.live_grep, {}) + vim.keymap.set('n', 'fb', builtin.buffers, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + end, +} diff --git a/.config/nvim/lua/kamu/plugins/tmux.lua b/.config/nvim/lua/kamu/plugins/tmux.lua new file mode 100644 index 0000000..59097de --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/tmux.lua @@ -0,0 +1,51 @@ +return {} +--return { +-- "aserowy/tmux.nvim", +-- config = function() +-- return require("tmux").setup({ +-- copy_sync = { +-- -- enables copy sync. by default, all registers are synchronized. +-- -- to control which registers are synced, see the `sync_*` options. +-- enable = true, +-- -- ignore specific tmux buffers e.g. buffer0 = true to ignore the +-- -- first buffer or named_buffer_name = true to ignore a named tmux +-- -- buffer with name named_buffer_name :) +-- ignore_buffers = { empty = false }, +-- -- TMUX >= 3.2: all yanks (and deletes) will get redirected to system +-- -- clipboard by tmux +-- redirect_to_clipboard = false, +-- -- offset controls where register sync starts +-- -- e.g. offset 2 lets registers 0 and 1 untouched +-- register_offset = 0, +-- -- overwrites vim.g.clipboard to redirect * and + to the system +-- -- clipboard using tmux. If you sync your system clipboard without tmux, +-- -- disable this option! +-- sync_clipboard = true, +-- -- synchronizes registers *, +, unnamed, and 0 till 9 with tmux buffers. +-- sync_registers = true, +-- -- syncs deletes with tmux clipboard as well, it is adviced to +-- -- do so. Nvim does not allow syncing registers 0 and 1 without +-- -- overwriting the unnamed register. Thus, ddp would not be possible. +-- sync_deletes = true, +-- -- syncs the unnamed register with the first buffer entry from tmux. +-- sync_unnamed = true, +-- }, +-- navigation = { +-- -- cycles to opposite pane while navigating into the border +-- cycle_navigation = true, +-- -- enables default keybindings (C-hjkl) for normal mode +-- enable_default_keybindings = true, +-- -- prevents unzoom tmux when navigating beyond vim border +-- persist_zoom = false, +-- }, +-- resize = { +-- -- enables default keybindings (A-hjkl) for normal mode +-- enable_default_keybindings = true, +-- -- sets resize steps for x axis +-- resize_step_x = 1, +-- -- sets resize steps for y axis +-- resize_step_y = 1, +-- } +-- }) +-- end +--} diff --git a/.config/nvim/lua/kamu/plugins/tree.lua b/.config/nvim/lua/kamu/plugins/tree.lua new file mode 100644 index 0000000..f54751d --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/tree.lua @@ -0,0 +1,26 @@ +return { + 'nvim-tree/nvim-tree.lua', + config = function() + local function my_on_attach(bufnr) + local api = require "nvim-tree.api" + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set('n', '', api.tree.change_root_to_parent, opts('Up')) + vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) + end + + -- pass to setup along with your other options + require("nvim-tree").setup { + --- + on_attach = my_on_attach, + --- + } + end +} diff --git a/.config/nvim/lua/kamu/plugins/treesitter.lua b/.config/nvim/lua/kamu/plugins/treesitter.lua new file mode 100644 index 0000000..5c1d70b --- /dev/null +++ b/.config/nvim/lua/kamu/plugins/treesitter.lua @@ -0,0 +1,33 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = { + "c", + "cpp", + "bash", + "lua", + "vim", + "vimdoc", + "json", + "python", + "yaml", + "markdown", + "make", + "query", + "javascript", + "dockerfile", + "html", + "latex", + "css", + "scss", + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} +