diff --git a/README.md b/README.md index 860ba6e7..cf1e767f 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,65 @@ What is in it? * *Neovimacs*: modeless editing support, with common Emacs bindings in insert mode * *Esc*: to toggle between insert (emacs bindings) and normal (neovim mode) * *Tabs*: Prev (F1), Next (F2), New (F3), and Close (F4) to jump around +* *Tool Tabs*: Terminal (F5) * *Movement*: Arrows and Tabs (and, yes, I know) * *Batteries*: Python LSP, completion, treesitter ## 📦 Installation +#### Prep + +Suggested: + +```bash +sudo apt install -y gcc python3-pip python3-venv git make unzip ripgrep gzip wget curl fd-find npm +sudo npm install -g tree-sitter-cli +``` + +Optional based on use-case: + +```bash +sudo apt install -y golang luarocks cargo nodejs clang python3-pynvim +``` + +#### Cloning + ```bash cd ~/.config -git clone git@github.com:millerjason/neovimrc.git +git clone https://github.com/millerjason/neovimrc.git ln -s neovimrc nvim ``` +#### Maint + +``` +:Lazy - upgrade packages +:Mason - build external tools +``` + +## Life with Neovim + +#### Do you have everything and is it working correctly? + +Checking overall health and options: + +``` +:CheckHealth +:lua print(vim.inspect(vim.opt.XXXX)) +:set option? +``` + +Beyond [which-key](https://github.com/folke/which-key.nvim), you can use the following +nvim commands to help you track down key bindings and resolve conflicts: + +``` +:verbose imap -- for insert mode +:verbose nmap -- for normal mode +:nmap -- to see leader commands +:WhichKey -- see above +``` + + ### References Kickstart: [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) diff --git a/init.lua b/init.lua index 09aabcd3..ac5276aa 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,19 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' vim.g.have_nerd_font = true +local function nvim_ver(major, minor) + local version = vim.version() + return (version.major > major or version.minor >= minor) +end + +-- fs_stat moves based on version :( +local fs_stat = function() + if nvim_ver(0, 10) then + return vim.uv.fs_stat + end + return vim.loop.fs_stat +end + -- Margins vim.opt.title = false -- in status, not great with tmux vim.opt.number = true -- show line number @@ -22,8 +35,11 @@ vim.opt.mouse = 'nvi' -- File related vim.opt.autochdir = false +vim.opt.swapfile = false +vim.opt.backup = false vim.opt.writebackup = false vim.opt.undofile = true +vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' if vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then vim.opt.fileformats = 'dos,unix,mac' elseif vim.fn.has 'mac' == 1 then @@ -76,7 +92,8 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- Install Lazy from Github local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.uv.fs_stat(lazypath) then + +if not fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } if vim.v.shell_error ~= 0 then @@ -95,6 +112,11 @@ require('lazy').setup({ 'millerjason/neovimacs.nvim', opts = {}, }, + -- { + -- dir = '/Users/jason/github/neovimacs.nvim', + -- name = 'neovimacs.nvim', + -- opts = {}, + -- }, -- Add git changes to gutter { @@ -111,7 +133,8 @@ require('lazy').setup({ }, -- Shows keybindings as you go - { + -- this technically requires >= 0.9.4 + unpack(nvim_ver(0, 10) and { 'folke/which-key.nvim', event = 'VimEnter', config = function() @@ -127,7 +150,7 @@ require('lazy').setup({ { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, } end, - }, + } or {}), -- Fuzzy finder (file & lsp) -- :Telescope help_tags @@ -643,16 +666,24 @@ local function safe_tabclose() vim.cmd 'tabclose' end end +vim.keymap.set('t', '', vim.cmd.tabp, { noremap = true, silent = true }) +vim.keymap.set('t', '', vim.cmd.tabn, { noremap = true, silent = true }) +vim.keymap.set('t', '', ':tabnew', { noremap = true, silent = true }) +vim.keymap.set('t', '', ':tabnew', { noremap = true, silent = true }) +vim.keymap.set('t', '', safe_tabclose, { noremap = true, silent = true }) +vim.keymap.set('t', '', ':tab new', { noremap = true, silent = true }) vim.keymap.set('n', '', vim.cmd.tabp, { noremap = true, silent = true }) vim.keymap.set('n', '', vim.cmd.tabn, { noremap = true, silent = true }) vim.keymap.set('n', '', ':tabnew', { noremap = true, silent = true }) vim.keymap.set('n', '', ':tabnew', { noremap = true, silent = true }) vim.keymap.set('n', '', safe_tabclose, { noremap = true, silent = true }) +vim.keymap.set('n', '', ':tab term', { noremap = true, silent = true }) vim.keymap.set('i', '', vim.cmd.tabp, { noremap = true, silent = true }) vim.keymap.set('i', '', vim.cmd.tabn, { noremap = true, silent = true }) vim.keymap.set('i', '', ':tabnew', { noremap = true, silent = true }) vim.keymap.set('i', '', ':tabnew', { noremap = true, silent = true }) vim.keymap.set('i', '', safe_tabclose, { noremap = true, silent = true }) +vim.keymap.set('i', '', ':tab term', { noremap = true, silent = true }) vim.keymap.set('n', 'tp', vim.cmd.tabn, { desc = 'Tab [p]revious' }) vim.keymap.set('n', 'tn', vim.cmd.tabp, { desc = 'Tab [n]ext' }) vim.keymap.set('n', 'to', vim.cmd.tabnew, { desc = 'Tab [o]pen' }) diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua deleted file mode 100644 index 87a7e5ff..00000000 --- a/lua/kickstart/plugins/autopairs.lua +++ /dev/null @@ -1,16 +0,0 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, -}