nvim

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

commit 7b85ed703d90fbd114a3520c44815c56b4bd7079
parent a5ccf0ff71270799b4cf7c313dc50b723273244f
Author: Inoue Yosuke <[email protected]>
Date:   Fri, 23 Dec 2022 23:55:59 +0900

set shell variable properly on linux

Diffstat:
M.gitignore | 2+-
Minit.lua | 38+++++++++++++++++++-------------------
Mlua/plugins.lua | 214++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mlua/terminal.lua | 48++++++++++++++++++++++++------------------------
4 files changed, 151 insertions(+), 151 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1 @@ -plugin/ +plugin/ diff --git a/init.lua b/init.lua @@ -1,19 +1,19 @@ --- 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.o.fileformats = "unix,dos" -vim.o.statusline = "%F%m%h%w%=%l,%c %{&ff}:%{&fenc!=''?&fenc:&enc}" -vim.api.nvim_create_user_command("M", "marks", {}) - -require ('terminal') - -vim.api.nvim_create_user_command('PackerSync', function () - require('plugins').sync() -end, {}) - +-- 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.o.fileformats = "unix,dos" +vim.o.statusline = "%F%m%h%w%=%l,%c %{&ff}:%{&fenc!=''?&fenc:&enc}" +vim.api.nvim_create_user_command("M", "marks", {}) + +require('terminal') + +vim.api.nvim_create_user_command('PackerSync', function () + require('plugins').sync() +end, {}) + diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -1,107 +1,107 @@ --- 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 'tpope/vim-commentary' - 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 { - 'nvim-tree/nvim-tree.lua', - config = function() - vim.o.termguicolors = true - require('nvim-tree').setup({ - filesystem_watchers = { - enable = false, - }, - 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 = '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 - +-- 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 'tpope/vim-commentary' + 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 { + 'nvim-tree/nvim-tree.lua', + config = function() + vim.o.termguicolors = true + require('nvim-tree').setup({ + filesystem_watchers = { + enable = false, + }, + 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 = '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 @@ -1,24 +1,24 @@ --- vim: expandtab:ts=2:sw=2 - -vim.keymap.set('n', '<C-w><C-e>', ':tabe<CR>:terminal<CR>i') -vim.keymap.set('t', [[<C-\><C-\>]], [[<C-\><C-n>]]) - -vim.api.nvim_create_autocmd('TermClose', { - pattern = '*', - command = [[if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif]], -}) - -if vim.fn.has('win32') then - -- @see :h shell-powershell - if vim.fn.executable('pwsh') == 1 then - vim.o.shell = 'pwsh' - else - vim.o.shell = 'powershell' - end - 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 - +-- vim: expandtab:ts=2:sw=2 + +vim.keymap.set('n', '<C-w><C-e>', ':tabe<CR>:terminal<CR>i') +vim.keymap.set('t', [[<C-\><C-\>]], [[<C-\><C-n>]]) + +vim.api.nvim_create_autocmd('TermClose', { + pattern = '*', + command = [[if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif]], +}) + +if vim.fn.has('win32') == 1 then + -- @see :h shell-powershell + if vim.fn.executable('pwsh') == 1 then + vim.o.shell = 'pwsh' + else + vim.o.shell = 'powershell' + end + 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 +