nvim

Personal nvim configurations
git clone https://git.kamikakushi.net/nvim.git
Log | Files | Refs | LICENSE

commit c835add552a3296e0c5681d49af72efb413ce1d5
Author: Inoue Yosuke <[email protected]>
Date:   Wed, 16 Nov 2022 15:12:57 +0900

Initial commit

Diffstat:
A.gitignore | 1+
Ainit.lua | 18++++++++++++++++++
Alua/plugins.lua | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/terminal.lua | 12++++++++++++
4 files changed, 158 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +plugin/ diff --git a/init.lua b/init.lua @@ -0,0 +1,18 @@ +-- vim: expandtab:ts=2:sw=2 + +-- disable netrw +-- https://github.com/nvim-tree/nvim-tree.lua#setup +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- opts +vim.o.backup = false +vim.api.nvim_create_user_command("M", "marks", {}) +vim.api.nvim_create_user_command("Q", "qa", {}) + +require('terminal') + +vim.api.nvim_create_user_command('PackerSync', function () + require('plugins').sync() +end, {}) + diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -0,0 +1,127 @@ +-- vim: expandtab:ts=2:sw=2 + +-- https://github.com/wbthomason/packer.nvim#bootstrapping +local function bootstrap_packer() + local fn = vim.fn + local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +-- https://github.com/wbthomason/dotfiles/blob/main/dot_config/nvim/lua/plugins.lua +local packer = nil +local function init() + local is_boostrapped = bootstrap_packer() + + if packer == nil then + packer = require('packer') + packer.init({disable_commands = true}) + end + + local use = packer.use + packer.reset() + + use 'wbthomason/packer.nvim' + use 'sirtaj/vim-maildrop' + use { + 'sindrets/diffview.nvim', + requires = 'nvim-lua/plenary.nvim', + config = function() + require("diffview").setup({ + use_icons = false, + signs = { + fold_closed = '-', + fold_open = '+', + }, + }) + vim.api.nvim_create_user_command("DO", "DiffviewOpen", {}) + end + } + use { + 'akinsho/toggleterm.nvim', + config = function() + require("toggleterm").setup({ + auto_scroll = true, + autochdir = true, + close_on_exit = true, + open_mapping = [[<C-\>]], + shell = vim.o.shell, + start_in_insert = true, + terminal_mappings = true, + }) + end + } + use { + 'nvim-tree/nvim-tree.lua', + after = 'toggleterm.nvim', + config = function() + vim.o.termguicolors = true + require('nvim-tree').setup({ + hijack_directories = { + enable = true, + auto_open = true, + }, + open_on_setup = true, + renderer = { + indent_markers = { enable = true }, + icons = { + glyphs = { + bookmark = '!', + }, + show = { + file = false, + folder = false, + folder_arrow = false, + git = false, + } + }, + }, + sync_root_with_cwd = true, + view = { + mappings = { + list = { + { + key = 'gt', + action = 'open_terminal', + action_cb = function(node) + if node.type == 'directory' then + vim.cmd('ToggleTerm dir="' .. node.absolute_path .. '"') + end + end, + }, + { + key = 'gp', + action = 'set_parent', + action_cb = function(node) + if node.type == 'directory' then + vim.fn.chdir(node.absolute_path) + end + end, + }, + }, + }, + }, + }) + vim.keymap.set('n', '<C-w><C-b>', ':NvimTreeToggle<CR>') + vim.keymap.set('n', '<C-w><C-g>', require("nvim-tree.api").marks.navigate.select) + end + } + + if is_boostrapped then + packer.sync() + end +end + +local plugins = setmetatable({}, { + __index = function(_, key) + init() + return packer[key] + end, +}) + +return plugins + diff --git a/lua/terminal.lua b/lua/terminal.lua @@ -0,0 +1,12 @@ +-- vim: expandtab:ts=2:sw=2 + +if vim.fn.has('win32') then + -- https://github.com/akinsho/toggleterm.nvim/wiki/Tips-and-Tricks#using-toggleterm-with-powershell + vim.o.shell = 'powershell.exe' + vim.o.shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' + vim.o.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' + vim.o.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + vim.o.shellquote = '' + vim.o.shellxquote = '' +end +