diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index af84cf9..41a826e 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -3,21 +3,21 @@ vim.g.mapleader = " " -- {{{ Plugins 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, - }) + 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) require("lazy").setup({ - { + { 'christoomey/vim-tmux-navigator', - config = function () + config = function() vim.g.tmux_navigator_no_mappings = 1 vim.keymap.set('', '', ':TmuxNavigateLeft') vim.keymap.set('', '', ':TmuxNavigateDown') @@ -34,7 +34,7 @@ require("lazy").setup({ highlight = { enable = true }, indent = { enable = true }, }, - config = function (_, opts) + config = function(_, opts) require("nvim-treesitter.configs").setup(opts); end, }, @@ -48,7 +48,7 @@ require("lazy").setup({ vim.cmd [[colorscheme tokyodark]] end, }, - { + { "nvim-lualine/lualine.nvim", opts = { options = { @@ -58,24 +58,181 @@ require("lazy").setup({ config = true, }, { "nvim-tree/nvim-web-devicons", lazy = true }, + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + event = "User EnableIDE", + dependencies = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, -- Required + { 'williamboman/mason.nvim' }, -- Optional + { 'williamboman/mason-lspconfig.nvim' }, -- Optional + + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, -- Required + { 'hrsh7th/cmp-nvim-lsp' }, -- Required + { 'L3MON4D3/LuaSnip' }, -- Required + }, + config = function() + -- {{{ LSP config + local lsp = require('lsp-zero').preset({}) + + lsp.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp.default_keymaps({ buffer = bufnr }) + vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) + vim.keymap.set('x', 'f', 'lua vim.lsp.buf.format({async = true})', { buffer = true }) + end) + + -- (Optional) Configure lua language server for neovim + require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) + + lsp.setup() + + local cmp = require('cmp') + local cmp_action = require('lsp-zero').cmp_action() + + cmp.setup({ + mapping = { + [''] = cmp_action.luasnip_supertab(), + [''] = cmp_action.luasnip_shift_supertab(), + }, + window = { + completion = { + max_height = 10, + }, + }, + }) + -- }}} + end + }, + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function () + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', function() + builtin.find_files({ follow = true }) + end, {}) + vim.keymap.set('n', 'fg', builtin.git_files, {}) + vim.keymap.set('n', 'fo', builtin.buffers, {}) + vim.keymap.set('n', 'st', builtin.live_grep, {}) + vim.keymap.set('n', 'ss', builtin.lsp_dynamic_workspace_symbols, {}) + end + }, + { + 'lewis6991/gitsigns.nvim', + -- {{{ Git signs + opts = { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, {expr=true}) + + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, {expr=true}) + + -- Actions + map('n', 'gs', gs.stage_hunk) + map('n', 'gr', gs.reset_hunk) + map('v', 'gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('v', 'gr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('n', 'gu', gs.undo_stage_hunk) + map('n', 'gR', gs.reset_buffer) + map('n', 'gp', gs.preview_hunk) + map('n', 'gl', function() gs.blame_line{full=true} end) + map('n', 'gt', gs.toggle_current_line_blame) + map('n', 'gj', gs.next_hunk) + map('n', 'gk', gs.prev_hunk) + + -- Text object + map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') + end + }, + -- }}} + config = true, + event = "User EnableIDE", + }, + { + 'tpope/vim-fugitive', + event = "User EnableIDE", + }, }) -- }}} - --- folding -vim.opt.foldmethod = "marker" +-- {{{ Keymap -- quick vertical movement vim.keymap.set('', '', '10j') vim.keymap.set('', '', '10k') --- tabs -vim.opt.expandtab = true -vim.opt.tabstop = 4 -vim.opt.shiftwidth = 4 - -- buffers vim.keymap.set('', 'H', 'bprevious'); vim.keymap.set('', 'L', 'bnext'); +-- do not exit visual mode when indenting +vim.keymap.set('v', '<', '', '>gv') + +-- close buffer with confirm +vim.keymap.set('n', 'c', ':confirm bdelete') + +-- copy to system clipboard +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set("n", "fv", "Ex") +-- }}} +-- {{{ Vim options + +-- tabs +vim.opt.expandtab = true +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.smartindent = true + + -- disable modeline vim.opt.modeline = false + +-- folding +vim.opt.foldmethod = "marker" + +vim.opt.relativenumber = true + +vim.opt.scrolloff = 8 + +vim.opt.wrap = false + +-- undos +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.termguicolors = true + +-- }}} +-- {{{ IDE mode +vim.api.nvim_create_user_command("IDE", function () + vim.api.nvim_exec_autocmds("User", { pattern = "EnableIDE" }) +end, {}) +if os.getenv("NVIM_IDE_MODE") == "1" then + vim.cmd [[IDE]] +end +-- }}} diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 2bed539..e7d214e 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,8 +1,19 @@ { + "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "gitsigns.nvim": { "branch": "main", "commit": "d8590288417fef2430f85bc8b312fae8b1cf2c40" }, "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "f084f4a6a716f55bf9c4026e73027bb24a0325a3" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, + "mason.nvim": { "branch": "main", "commit": "c811fbf09c7642eebb37d6694f1a016a043f6ed3" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, "nvim-treesitter": { "branch": "master", "commit": "cb74c1c5aefd8b903f1b547d08d4df42be07aa2a" }, "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, + "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "tokyodark.nvim": { "branch": "master", "commit": "4bfb42924274abc5de9f5f4779075b77c6112c85" }, + "vim-fugitive": { "branch": "master", "commit": "572c8510123cbde02e8a1dafcd376c98e1e13f43" }, "vim-tmux-navigator": { "branch": "master", "commit": "addb64a772cb4a3ae1f1363583012b2cada2cd66" } } \ No newline at end of file diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 09e7829..6c0ddf4 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -30,6 +30,17 @@ bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel set -g @catppuccin_flavour "mocha" set -g @catppuccin_status_modules "-" +# Session splitting +bind D kill-session +bind C-c \ + break-pane \ + \; run-shell 'urxvt -e tmux new \; move-window -s #{session_name}:#{window_id} \; kill-window -t 1 \; move-window -r &' \ + \; move-window -r + +bind C \ + run-shell 'urxvt -e tmux new \; move-window -s #{session_name}:#{window_id} \; kill-window -t 1 \; move-window -r &' \ + \; move-window -r + # Smart pane switching with awareness of Vim splits. # See: https://github.com/christoomey/vim-tmux-navigator is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ diff --git a/zsh/.zshrc b/zsh/.zshrc index 6c625c9..42cc1bf 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -12,7 +12,8 @@ export EDITOR="/usr/bin/nvim" export VISUAL="/usr/bin/nvim" alias activate-venv="source venv/bin/activate" alias rootvenv="source ~/.venv/bin/activate" -alias glvim="lvim -c 'set autoindent noexpandtab tabstop=4 shiftwidth=4'" +alias ide="NVIM_IDE_MODE=1 nvim" +alias gide="ide -c 'set autoindent noexpandtab tabstop=4 shiftwidth=4'" alias showkey="ssh-keygen -y -f" ffmpeg_compat() {