feat: vimux?
This commit is contained in:
parent
68f807ecf2
commit
26d59301f6
26
dotfiles/neovim/README.md
Normal file
26
dotfiles/neovim/README.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Neovim config
|
||||||
|
|
||||||
|
## Keybinds
|
||||||
|
|
||||||
|
Table of my own keybinds. Here as documentation for myself. I am yet to include any of the keybinds for the lspconfig, telescope or cmp here.
|
||||||
|
|
||||||
|
> Things written using italics are chords
|
||||||
|
|
||||||
|
| Keybind | Description | Plugins |
|
||||||
|
| ---------------- | -------------------------------- | --------------- |
|
||||||
|
| vv | Create vertical split | |
|
||||||
|
| \<Space>\<Space> | Save | |
|
||||||
|
| jj | Exit insert mode | |
|
||||||
|
| _vp_ | Run command in another tmux pane | vimux, arpeggio |
|
||||||
|
| C-n | Open tree | nvim-tree |
|
||||||
|
|
||||||
|
## Some cool vim keybinds I sometimes forget about
|
||||||
|
|
||||||
|
Documentation for myself
|
||||||
|
|
||||||
|
| Keybind | Description | Plugins |
|
||||||
|
| ------- | ----------------------- | ------------ |
|
||||||
|
| zz | Center the current line | |
|
||||||
|
| C-w C-r | Swap 2 splits | |
|
||||||
|
| gcc | Comment line | nvim-comment |
|
||||||
|
| gc | Comment selection | nvim-comment |
|
|
@ -7,8 +7,13 @@ end
|
||||||
function M.mergeTables(t1, t2)
|
function M.mergeTables(t1, t2)
|
||||||
local t3 = {}
|
local t3 = {}
|
||||||
|
|
||||||
for k, v in pairs(t1) do t3[k] = v end
|
if t1 ~= nil then
|
||||||
for k, v in pairs(t2) do t3[k] = v end
|
for k, v in pairs(t1) do t3[k] = v end
|
||||||
|
end
|
||||||
|
|
||||||
|
if t2 ~= nil then
|
||||||
|
for k, v in pairs(t2) do t3[k] = v end
|
||||||
|
end
|
||||||
|
|
||||||
return t3
|
return t3
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
local cmd = vim.cmd
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- Command for formatting lua code
|
-- Command for formatting lua code
|
||||||
|
@ -10,10 +9,19 @@ local function map(buf, mode, lhs, rhs, opts)
|
||||||
vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options)
|
vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_attach(client, bufnr)
|
function M.on_attach(client, bufnr)
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
if client.resolved_capabilities.document_formatting then
|
||||||
|
vim.cmd([[
|
||||||
|
augroup LspFormatting
|
||||||
|
autocmd! * <buffer>
|
||||||
|
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
|
||||||
|
augroup END
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
-- Go to declaration / definition / implementation
|
-- Go to declaration / definition / implementation
|
||||||
map(bufnr, "n", 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>')
|
map(bufnr, "n", 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>')
|
||||||
map(bufnr, "n", 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>')
|
map(bufnr, "n", 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>')
|
||||||
|
@ -40,7 +48,7 @@ local function on_attach_typescript(client, bufnr)
|
||||||
client.resolved_capabilities.document_formatting = false
|
client.resolved_capabilities.document_formatting = false
|
||||||
client.resolved_capabilities.document_range_formatting = false
|
client.resolved_capabilities.document_range_formatting = false
|
||||||
|
|
||||||
on_attach(client, bufnr)
|
M.on_attach(client, bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- General server config
|
-- General server config
|
||||||
|
@ -80,7 +88,7 @@ function M.setup()
|
||||||
for lsp, details in pairs(servers) do
|
for lsp, details in pairs(servers) do
|
||||||
if details.on_attach == nil then
|
if details.on_attach == nil then
|
||||||
-- Default setting for on_attach
|
-- Default setting for on_attach
|
||||||
details.on_attach = on_attach
|
details.on_attach = M.on_attach
|
||||||
end
|
end
|
||||||
|
|
||||||
require('lspconfig')[lsp].setup {
|
require('lspconfig')[lsp].setup {
|
||||||
|
@ -94,6 +102,7 @@ function M.setup()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: replace this with null-ls
|
||||||
local efmLanguages = {lua = {{formatCommand = formatLua, formatStdin = true}}}
|
local efmLanguages = {lua = {{formatCommand = formatLua, formatStdin = true}}}
|
||||||
|
|
||||||
-- Setup auto-formatting
|
-- Setup auto-formatting
|
||||||
|
@ -102,14 +111,6 @@ function M.setup()
|
||||||
filetypes = {"lua"},
|
filetypes = {"lua"},
|
||||||
settings = {rootMarkers = {".git/"}, languages = efmLanguages}
|
settings = {rootMarkers = {".git/"}, languages = efmLanguages}
|
||||||
}
|
}
|
||||||
|
|
||||||
local autoFormatOn = {lua = 200, purs = 1000, nix = 200, ts = 200, js = 200, json = 200, scss = 200, tsx = 200, jsx = 200}
|
|
||||||
|
|
||||||
-- Auto format
|
|
||||||
for extension, _ in pairs(autoFormatOn) do
|
|
||||||
-- I wonder if this could be done in a single glob pattern
|
|
||||||
cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync()")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
local lspconfig = require("my.plugins.lspconfig")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
local sources = {
|
local sources = {
|
||||||
null_ls.builtins.formatting.prettierd -- format ts files
|
null_ls.builtins.formatting.prettierd.with({extra_filetypes = {"markdown"}}) -- format ts files
|
||||||
}
|
}
|
||||||
|
|
||||||
null_ls.setup({sources = sources})
|
null_ls.setup({sources = sources, on_attach = lspconfig.on_attach})
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -3,7 +3,7 @@ local arpeggio = require("my.plugins.arpeggio")
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
arpeggio.chordSilent("n", "<Leader>vp", ":VimuxPromptCommand<CR>")
|
arpeggio.chordSilent("n", "vp", ":VimuxPromptCommand<CR>")
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
19
flake.lock
19
flake.lock
|
@ -336,7 +336,8 @@
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
"oh-my-fish": "oh-my-fish",
|
"oh-my-fish": "oh-my-fish",
|
||||||
"telescope-file-browser-nvim": "telescope-file-browser-nvim",
|
"telescope-file-browser-nvim": "telescope-file-browser-nvim",
|
||||||
"vim-extra-plugins": "vim-extra-plugins"
|
"vim-extra-plugins": "vim-extra-plugins",
|
||||||
|
"vim-plugin-arpeggio": "vim-plugin-arpeggio"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"telescope-file-browser-nvim": {
|
"telescope-file-browser-nvim": {
|
||||||
|
@ -374,6 +375,22 @@
|
||||||
"repo": "nixpkgs-vim-extra-plugins",
|
"repo": "nixpkgs-vim-extra-plugins",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vim-plugin-arpeggio": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1597883245,
|
||||||
|
"narHash": "sha256-volgKWr1mNwmvOQQEw7feBztmpDVyPJG1n+OI8L1BRA=",
|
||||||
|
"owner": "kana",
|
||||||
|
"repo": "vim-arpeggio",
|
||||||
|
"rev": "01c8fc1a72ef58e490ee0490c65ee313b1b6e843",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "kana",
|
||||||
|
"repo": "vim-arpeggio",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
|
|
||||||
vim-extra-plugins.url = "github:m15a/nixpkgs-vim-extra-plugins";
|
vim-extra-plugins.url = "github:m15a/nixpkgs-vim-extra-plugins";
|
||||||
|
|
||||||
|
# Plugin which enables me to create chords (aka keybinds where everything must be set at the same time)
|
||||||
|
vim-plugin-arpeggio = {
|
||||||
|
url = "github:kana/vim-arpeggio";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Create / delete files within telescope
|
# Create / delete files within telescope
|
||||||
telescope-file-browser-nvim = {
|
telescope-file-browser-nvim = {
|
||||||
url = "github:nvim-telescope/telescope-file-browser.nvim";
|
url = "github:nvim-telescope/telescope-file-browser.nvim";
|
||||||
|
|
|
@ -59,6 +59,7 @@ in
|
||||||
# symbols-outline-nvim # tree view for symbols in document
|
# symbols-outline-nvim # tree view for symbols in document
|
||||||
vimux # interact with tmux from within vim
|
vimux # interact with tmux from within vim
|
||||||
vim-tmux-navigator # easly switch between tmux and vim panes
|
vim-tmux-navigator # easly switch between tmux and vim panes
|
||||||
|
arpeggio # allows me to setup chord keybinds (keybinds where all the keys are pressed at the same time)
|
||||||
|
|
||||||
# Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp
|
# Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp
|
||||||
cmp-nvim-lsp
|
cmp-nvim-lsp
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
, oh-my-fish
|
, oh-my-fish
|
||||||
, githubNvimTheme
|
, githubNvimTheme
|
||||||
, vim-extra-plugins
|
, vim-extra-plugins
|
||||||
|
, vim-plugin-arpeggio
|
||||||
, telescope-file-browser-nvim
|
, telescope-file-browser-nvim
|
||||||
, ...
|
, ...
|
||||||
}: self: super:
|
}: self: super:
|
||||||
|
@ -63,5 +64,7 @@ in
|
||||||
myVimPlugins = {
|
myVimPlugins = {
|
||||||
telescope-file-browser-nvim =
|
telescope-file-browser-nvim =
|
||||||
plugin "file_browser" telescope-file-browser-nvim;
|
plugin "file_browser" telescope-file-browser-nvim;
|
||||||
|
|
||||||
|
arpeggio = plugin "arpeggio" vim-plugin-arpeggio;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue