Skip to content

Commit 4de7650

Browse files
committed
changes for easier usage and README
1 parent 8c3bbd1 commit 4de7650

File tree

9 files changed

+128
-50
lines changed

9 files changed

+128
-50
lines changed

README.md

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,115 @@
11
# Configuration files for `neovim`
22

3-
Nothing really special, just an average `neovim` config.
3+
To be used with my [dotfiles](https://github.com/kiddae/dotfiles)
44

5-
Run `ln -s /full/path/to/repo ~/.config/nvim` to link.
5+
Requires `[vim-plug]`(https://github.com/junegunn/vim-plug) to manage plugins.
66

7-
To be used with my [dotfiles](https://github.com/kiddae/dotfiles)
7+
# Installation
8+
9+
Clone the repository to `~/.config/nvim`. Install `vim-plug` using the command given in its repository. Run `nvim -c PlugInstall`. Voilà!
10+
11+
# Usage
12+
13+
## Navigation
14+
15+
Extending the normal vim keybindings, things I've added for myself can be found in `[commands.vim]`(commands.vim), mostly for managing buffers and files and navigating between windows/splits:
16+
17+
```
18+
"<leader> = space
19+
let mapleader = " "
20+
nnoremap <C-h> :wincmd h<CR> "navigates
21+
nnoremap <C-j> :wincmd j<CR>
22+
nnoremap <C-k> :wincmd k<CR>
23+
nnoremap <C-l> :wincmd l<CR>
24+
nnoremap <C-w> :wincmd w<CR>
25+
nnoremap <leader>h :wincmd H<CR> "moves
26+
nnoremap <leader>j :wincmd J<CR>
27+
nnoremap <leader>k :wincmd K<CR>
28+
nnoremap <leader>l :wincmd L<CR>
29+
nnoremap <leader>+ :vertical resize +5<CR> "resizes
30+
nnoremap <leader>- :vertical resize -5<CR>
31+
nnoremap <leader>> :vertical resize >5<CR>
32+
nnoremap <leader>< :vertical resize <5<CR>
33+
nnoremap <leader>= :winc =<CR>
34+
35+
"switching buffers/closing/new file
36+
nnoremap <S-tab> :bp<CR>
37+
nnoremap <tab> :bn<CR>
38+
nnoremap <C-q> :bp<bar>sp<bar>bn<bar>bd<CR>
39+
```
40+
41+
## Run and compile
42+
43+
In that same [`commands.vim`](commands.vim) file, you'll find the definition of command `RunSplit` which runs the shell command given as argument in a terminal window on the right. To complete this, the global dictionary `g:Rules` contains rules for any filetypes you want, as another dictionary with the compiling command and program run command, as well as a silent flag (as a boolean) to compile with `AsyncRun`. For example (from the `commands.vim` file itself):
44+
45+
```
46+
let g:Rules.cpp = {"compile": "g++ -o %< %", "run": "./%<", "silent": v:true}
47+
```
48+
49+
For project-specific configuration, just add a `.vimrc` file in the working directory containing the new definitions. They should reload automatically, but if it isn't the case, run `:call UpdateCommands()`.
50+
51+
The `Compile` and `RunProgram` commands can then be used, they are also mapped to `<F4>` and `<F5>` respectively.
52+
53+
## Language Server Protocol
54+
55+
This configuration uses `neovim`'s Language Server Protocol that is managed through the plugin [`nvim-lsp-installer`](https://github.com/williamboman/nvim-lsp-installer). To add a language server, head over to [`plugin/nvim-lspconfig.lua`](plugin/nvim-lspconfig.lua) and add it to the array at the top. You can get a list of the installed servers and the ones available with `:LspInstallInfo`. Note that some dependencies are required to properly install the servers, see the plugin's repository for more information.
56+
57+
The keybindings are very similar to the default ones given as example by `neovim`'s repository.
58+
59+
```lua
60+
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
61+
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
62+
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
63+
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
64+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>k', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
65+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
66+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
67+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
68+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
69+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
70+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
71+
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
72+
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
73+
```
74+
75+
## Debug-Adapter Protocol
76+
77+
I am using [`nvim-dap`](https://github.com/mfussenegger/nvim-dap) as a bridge to using debug adapters, as well as [`nvim-dap-ui`](https://github.com/gcarriga/nvim-dap-ui) as an intuitive user interface to debugging sessions.
78+
This requires the manual installation of the debug adapters, [`nvim-dap`'s wiki](https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation). I have configured `debugpy` and `vscode-cpptools`, with the virtualenv for `debugpy` in `~/.virtualenvs/debugpy/` and the binaries for `cpptools` in `~/Code/cpptools/`.
79+
80+
Keybindings are the ones given as example by the plugin:
81+
82+
```
83+
nnoremap <silent> <F5> :lua require'dap'.continue()<CR>
84+
nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>
85+
nnoremap <silent> <F11> :lua require'dap'.step_into()<CR>
86+
nnoremap <silent> <F12> :lua require'dap'.step_out()<CR>
87+
nnoremap <silent> <leader>b :lua require'dap'.toggle_breakpoint()<CR>
88+
nnoremap <silent> <leader>B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
89+
nnoremap <silent> <leader>lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
90+
nnoremap <silent> <leader>dr :lua require'dap'.repl.toggle()<CR>
91+
nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>
92+
nnoremap <silent> <leader>dq :lua require'dap'.terminate()<CR>
93+
```
94+
95+
## Others
96+
97+
### File explorer
98+
99+
I use ['nvim-tree'](https://github.com/kyazdani42/nvim-tree.lua). Fire it up with `Ctrl+n`, and to quickly learn how to use it, `g?` will show its keybindings.
100+
101+
### Telescope
102+
103+
Search for files in the current working directory with `<leader>ff` or recently opened files with `<leader>fh`, powered by [`telescope.nvim`](https://github.com/nvim-telescope/telescope.nvim)
104+
105+
### Auto-pairs
106+
107+
Brackets, parentheses etc. are closed automatically; to move the next word inside it, use `Ctrl+E` ([`auto-pairs`](https://github.com/jiangmiao/auto-pairs)).
108+
109+
### WhichKey?
8110

9-
Requires [vim-plug](https://github.com/junegunn/vim-plug) to manage plugins.
111+
[`WhichKey`](https://github.com/folke/which-key.nvim) is a little menu that shows the available binding in case you forget. You can fire it up with `<leader><F1>`, or it will do it automatically if you're starting a command.
10112

11-
## TODO
113+
### Snippets
12114

13-
+ [ ] Add my keybindings to README.
115+
(Only for LaTeX as of now) A bunch of handy snippets are configured in [`Ultisnips/`](Ultisnips/) for convenient use.

coc-settings.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

commands.vim

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set timeout timeoutlen=1000 ttimeoutlen=10
44
" inoremap jk <Esc>
55

66
"navigation
7-
nnoremap <leader>o :Files<CR>
8-
nnoremap <leader>O :Files $HOME<CR>
97
nnoremap <leader>u :UndotreeToggle<CR>
108
119
nnoremap <C-h> :wincmd h<CR> "navigates
@@ -27,9 +25,7 @@ nnoremap <leader>vr :so $MYVIMRC<CR>
2725
2826
nnoremap <S-tab> :bp<CR>
2927
nnoremap <tab> :bn<CR>
30-
nnoremap <silent> <C-s> :BufferPick<CR>
31-
nnoremap <C-q> :bdelete<CR>
32-
nnoremap <C-n> :enew<CR>
28+
nnoremap <C-q> :bp<bar>sp<bar>bn<bar>bd<CR>
3329
nnoremap <leader>r :RunSplit ranger<CR>
3430
nnoremap <leader>t :RunSplit $SHELL<CR>
3531
nnoremap <leader>T :ExtTerm <CR>

plugin/dashboard.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
let g:dashboard_default_executive='telescope'
2-
" let g:dashboard_default_header='pikachu'
32
" let g:dashboard_preview_command = 'chafa -f symbols -c 256 --fg-only --symbols braille'
43
" let g:dashboard_preview_file = '~/.config/nvim/LAINHADN3.gif'
54
let g:dashboard_preview_file_height = 14

plugin/nvim-lspconfig.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- List of servers
2+
local servers = { 'pyright', 'clangd', 'tsserver', 'bashls', 'ltex', 'ocamllsp', 'html', 'cssls', 'vimls', 'sumneko_lua' }
3+
14
-- Mappings.
25
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
36
local opts = { noremap = true, silent = true }
@@ -34,7 +37,6 @@ end
3437

3538
-- Use a loop to conveniently call 'setup' on multiple servers and
3639
-- map buffer local keybindings when the language server attaches
37-
local servers = { 'pyright', 'clangd', 'tsserver', 'bashls', 'ltex', 'ocamllsp', 'html', 'cssls', 'vimls', 'sumneko_lua' }
3840
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
3941
for _, lsp in pairs(servers) do
4042
require('lspconfig')[lsp].setup {

plugin/nvim-tree.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require 'nvim-tree'.setup {
2929
ignore_ft_on_setup = { "dashboard" },
3030
view = {
3131
hide_root_folder = true,
32-
width = 35
32+
width = 25
3333
},
3434
actions = {
3535
open_file = {

plugins.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Plug 'projekt0n/github-nvim-theme'
1212
Plug 'shaunsingh/nord.nvim'
1313
Plug 'NLKNguyen/papercolor-theme'
1414
Plug 'ayu-theme/ayu-vim'
15-
let g:ayucolor = "dark"
15+
let g:ayucolor = "light"
1616
Plug 'kaicataldo/material.vim', { 'branch': 'main' }
1717
Plug 'mangeshrex/everblush.vim'
1818
Plug 'catppuccin/nvim', {'as': 'catppuccin', 'branch': 'main'}
@@ -27,10 +27,10 @@ Plug 'sainnhe/forest-night'
2727
Plug 'nvim-lualine/lualine.nvim'
2828
Plug 'akinsho/bufferline.nvim', { 'tag': 'v2.*' }
2929
Plug 'kyazdani42/nvim-web-devicons' "dependency of barbar
30-
Plug 'kyazdani42/nvim-tree.lua'
3130
" Plug 'romgrk/barbar.nvim'
3231

3332
"" IDE-LIKE FEATURES
33+
Plug 'kyazdani42/nvim-tree.lua'
3434
Plug 'neovim/nvim-lspconfig'
3535
Plug 'williamboman/nvim-lsp-installer'
3636
Plug 'hrsh7th/cmp-nvim-lsp'

spell/fr.utf-8.add

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,16 @@ sectionnable
6767
micro-contrôleur
6868
millisecondes
6969
Kero
70+
mind-blowingly
71+
dotfiles
72+
dotfiles
73+
dotfiles
74+
dotfiles
75+
dotfiles
76+
dotfiles
77+
dotfiles
78+
dotfiles
79+
dotfiles
80+
boolean
81+
filetype
82+
filetypes

spell/fr.utf-8.add.spl

66 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)