Merge pull request #2 from millerjason/jason

updates 20241117
This commit is contained in:
Jason Miller 2024-11-17 18:44:32 -05:00 committed by GitHub
commit 73a5429f2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 83 additions and 20 deletions

View File

@ -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 <C-n> -- for insert mode
:verbose nmap <C-n> -- for normal mode
:nmap <localleader> -- to see leader commands
:WhichKey -- see above
```
### References
Kickstart: [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim)

View File

@ -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({
{ '<leader>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', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
vim.keymap.set('t', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
vim.keymap.set('t', '<F3>', '<C-\\><C-n>:tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('t', '', '<C-\\><C-n>:tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('t', '<F4>', safe_tabclose, { noremap = true, silent = true })
vim.keymap.set('t', '<F5>', '<C-\\><C-n><Esc>:tab new<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
vim.keymap.set('n', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
vim.keymap.set('n', '<F3>', ':tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '', ':tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<F4>', safe_tabclose, { noremap = true, silent = true })
vim.keymap.set('n', '<F5>', ':tab term<CR>', { noremap = true, silent = true })
vim.keymap.set('i', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
vim.keymap.set('i', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
vim.keymap.set('i', '<F3>', '<Esc>:tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('i', '', '<Esc>:tabnew<CR>', { noremap = true, silent = true })
vim.keymap.set('i', '<F4>', safe_tabclose, { noremap = true, silent = true })
vim.keymap.set('i', '<F5>', '<Esc>:tab term<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<leader>tp', vim.cmd.tabn, { desc = 'Tab [p]revious' })
vim.keymap.set('n', '<leader>tn', vim.cmd.tabp, { desc = 'Tab [n]ext' })
vim.keymap.set('n', '<leader>to', vim.cmd.tabnew, { desc = 'Tab [o]pen' })

View File

@ -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,
}