1
Fork 0

feat: vimux?

This commit is contained in:
Matei Adriel 2022-03-09 20:44:21 +02:00
parent 68f807ecf2
commit 26d59301f6
9 changed files with 79 additions and 18 deletions

26
dotfiles/neovim/README.md Normal file
View 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 |

View file

@ -7,8 +7,13 @@ end
function M.mergeTables(t1, t2)
local t3 = {}
for k, v in pairs(t1) do t3[k] = v end
for k, v in pairs(t2) do t3[k] = v end
if t1 ~= nil then
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
end

View file

@ -1,4 +1,3 @@
local cmd = vim.cmd
local M = {}
-- 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)
end
local function on_attach(client, bufnr)
function M.on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
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
map(bufnr, "n", 'gD', '<cmd>lua vim.lsp.buf.declaration()<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_range_formatting = false
on_attach(client, bufnr)
M.on_attach(client, bufnr)
end
-- General server config
@ -80,7 +88,7 @@ function M.setup()
for lsp, details in pairs(servers) do
if details.on_attach == nil then
-- Default setting for on_attach
details.on_attach = on_attach
details.on_attach = M.on_attach
end
require('lspconfig')[lsp].setup {
@ -94,6 +102,7 @@ function M.setup()
}
end
-- TODO: replace this with null-ls
local efmLanguages = {lua = {{formatCommand = formatLua, formatStdin = true}}}
-- Setup auto-formatting
@ -102,14 +111,6 @@ function M.setup()
filetypes = {"lua"},
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
return M

View file

@ -1,13 +1,15 @@
local lspconfig = require("my.plugins.lspconfig")
local M = {}
function M.setup()
local null_ls = require("null-ls")
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
return M

View file

@ -3,7 +3,7 @@ local arpeggio = require("my.plugins.arpeggio")
local M = {}
function M.setup()
arpeggio.chordSilent("n", "<Leader>vp", ":VimuxPromptCommand<CR>")
arpeggio.chordSilent("n", "vp", ":VimuxPromptCommand<CR>")
end
return M

View file

@ -336,7 +336,8 @@
"nixpkgs-unstable": "nixpkgs-unstable",
"oh-my-fish": "oh-my-fish",
"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": {
@ -374,6 +375,22 @@
"repo": "nixpkgs-vim-extra-plugins",
"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",

View file

@ -17,6 +17,12 @@
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
telescope-file-browser-nvim = {
url = "github:nvim-telescope/telescope-file-browser.nvim";

View file

@ -59,6 +59,7 @@ in
# symbols-outline-nvim # tree view for symbols in document
vimux # interact with tmux from within vim
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-nvim-lsp

View file

@ -12,6 +12,7 @@
, oh-my-fish
, githubNvimTheme
, vim-extra-plugins
, vim-plugin-arpeggio
, telescope-file-browser-nvim
, ...
}: self: super:
@ -63,5 +64,7 @@ in
myVimPlugins = {
telescope-file-browser-nvim =
plugin "file_browser" telescope-file-browser-nvim;
arpeggio = plugin "arpeggio" vim-plugin-arpeggio;
};
}