home: create 'modules/home' folder
Consolidating all modules under the same path, to clear out the top-level directory.
This commit is contained in:
parent
c856933803
commit
65a8f7c481
119 changed files with 2 additions and 2 deletions
9
modules/home/vim/after/ftplugin/beancount.vim
Normal file
9
modules/home/vim/after/ftplugin/beancount.vim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on beancount files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
|
||||
" Have automatic padding of transactions so that decimal is on 52nd column
|
||||
let g:beancount_separator_col=52
|
||||
6
modules/home/vim/after/ftplugin/cmake.vim
Normal file
6
modules/home/vim/after/ftplugin/cmake.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use 2 spaces indentation inside CMake files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
6
modules/home/vim/after/ftplugin/fugitive.vim
Normal file
6
modules/home/vim/after/ftplugin/fugitive.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Don't highlight trailing whitespace in fugitive windows
|
||||
let b:better_whitespace_enabled=0
|
||||
let b:undo_ftplugin.='|unlet! b:better_whitespace_enabled'
|
||||
10
modules/home/vim/after/ftplugin/gitcommit.vim
Normal file
10
modules/home/vim/after/ftplugin/gitcommit.vim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Enable spell checking on commit messages
|
||||
setlocal spell
|
||||
let b:undo_ftplugin.='|setlocal spell<'
|
||||
|
||||
" Change max length of a line to 72 for this buffer
|
||||
setlocal colorcolumn=72
|
||||
let b:undo_ftplugin.='|setlocal colorcolumn<'
|
||||
6
modules/home/vim/after/ftplugin/gitconfig.vim
Normal file
6
modules/home/vim/after/ftplugin/gitconfig.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Git configuration files should use tabs to indent
|
||||
setlocal noexpandtab
|
||||
let b:undo_ftplugin.='|setlocal noexpandtab<'
|
||||
10
modules/home/vim/after/ftplugin/haskell.vim
Normal file
10
modules/home/vim/after/ftplugin/haskell.vim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on Haskell files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
|
||||
" Change max length of a line to 100 for this buffer to match official guidelines
|
||||
setlocal colorcolumn=100
|
||||
let b:undo_ftplugin.='|setlocal colorcolumn<'
|
||||
6
modules/home/vim/after/ftplugin/help.vim
Normal file
6
modules/home/vim/after/ftplugin/help.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Don't highlight trailing whitespace in help windows
|
||||
let b:better_whitespace_enabled=0
|
||||
let b:undo_ftplugin.='|unlet! b:better_whitespace_enabled'
|
||||
6
modules/home/vim/after/ftplugin/mail.vim
Normal file
6
modules/home/vim/after/ftplugin/mail.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Change max length of a line to 72 to follow the netiquette
|
||||
setlocal colorcolumn=72
|
||||
let b:undo_ftplugin.='|setlocal colorcolumn<'
|
||||
6
modules/home/vim/after/ftplugin/make.vim
Normal file
6
modules/home/vim/after/ftplugin/make.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Makefiles should use tabs to indent
|
||||
setlocal noexpandtab
|
||||
let b:undo_ftplugin.='|setlocal noexpandtab<'
|
||||
10
modules/home/vim/after/ftplugin/markdown.vim
Normal file
10
modules/home/vim/after/ftplugin/markdown.vim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on Pandoc files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
|
||||
" Use my usual text width
|
||||
setlocal textwidth=80
|
||||
let b:undo_ftplugin.='|setlocal textwidth<'
|
||||
6
modules/home/vim/after/ftplugin/netrw.vim
Normal file
6
modules/home/vim/after/ftplugin/netrw.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Don't show Netrw in buffer list
|
||||
setlocal bufhidden=delete
|
||||
let b:undo_ftplugin='|setlocal bufhidden<'
|
||||
6
modules/home/vim/after/ftplugin/nix.vim
Normal file
6
modules/home/vim/after/ftplugin/nix.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on Nix files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
6
modules/home/vim/after/ftplugin/python.vim
Normal file
6
modules/home/vim/after/ftplugin/python.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Change max length of a line to 88 for this buffer to match black's settings
|
||||
setlocal colorcolumn=88
|
||||
let b:undo_ftplugin.='|setlocal colorcolumn<'
|
||||
6
modules/home/vim/after/ftplugin/rust.vim
Normal file
6
modules/home/vim/after/ftplugin/rust.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Change max length of a line to 99 for this buffer to match official guidelines
|
||||
setlocal colorcolumn=99
|
||||
let b:undo_ftplugin.='|setlocal colorcolumn<'
|
||||
6
modules/home/vim/after/ftplugin/tex.vim
Normal file
6
modules/home/vim/after/ftplugin/tex.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use 2 spaces indentation inside TeX files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
6
modules/home/vim/after/ftplugin/tiger.vim
Normal file
6
modules/home/vim/after/ftplugin/tiger.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on tiger files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
6
modules/home/vim/after/ftplugin/yaml.vim
Normal file
6
modules/home/vim/after/ftplugin/yaml.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
call ftplugined#check_undo_ft()
|
||||
|
||||
" Use a small indentation value on YAML files
|
||||
setlocal shiftwidth=2
|
||||
let b:undo_ftplugin.='|setlocal shiftwidth<'
|
||||
10
modules/home/vim/after/plugin/mappings/commentary.lua
Normal file
10
modules/home/vim/after/plugin/mappings/commentary.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
local wk = require("which-key")
|
||||
|
||||
local keys = {
|
||||
name = "Comment/uncomment",
|
||||
c = "Current line",
|
||||
u = "Uncomment the current and adjacent commented lines",
|
||||
["gc"] = "Uncomment the current and adjacent commented lines",
|
||||
}
|
||||
|
||||
wk.register(keys, { prefix = "gc" })
|
||||
7
modules/home/vim/after/plugin/mappings/misc.lua
Normal file
7
modules/home/vim/after/plugin/mappings/misc.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
local wk = require("which-key")
|
||||
|
||||
local keys = {
|
||||
["<leader>"] = { "<cmd>nohls<CR>", "Clear search highlight" },
|
||||
}
|
||||
|
||||
wk.register(keys, { prefix = "<leader>" })
|
||||
15
modules/home/vim/after/plugin/mappings/telescope.lua
Normal file
15
modules/home/vim/after/plugin/mappings/telescope.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
local wk = require("which-key")
|
||||
local telescope_builtin = require("telescope.builtin")
|
||||
|
||||
local keys = {
|
||||
f = {
|
||||
name = "Fuzzy finder",
|
||||
b = { telescope_builtin.buffers, "Open buffers" },
|
||||
f = { telescope_builtin.git_files, "Git tracked files" },
|
||||
F = { telescope_builtin.find_files, "Files" },
|
||||
g = { telescope_builtin.live_grep, "Grep string" },
|
||||
G = { telescope_builtin.grep_string, "Grep string under cursor" },
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys, { prefix = "<leader>" })
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
local wk = require("which-key")
|
||||
|
||||
local motions = {
|
||||
["]m"] = "Next method start",
|
||||
["]M"] = "Next method end",
|
||||
["]S"] = "Next statement start",
|
||||
["]]"] = "Next class start",
|
||||
["]["] = "Next class end",
|
||||
["[m"] = "Previous method start",
|
||||
["[M"] = "Previous method end",
|
||||
["[S"] = "Previous statement start",
|
||||
["[["] = "Previous class start",
|
||||
["[]"] = "Previous class end",
|
||||
}
|
||||
|
||||
local objects = {
|
||||
["aa"] = "a parameter",
|
||||
["ia"] = "inner parameter",
|
||||
["ab"] = "a block",
|
||||
["ib"] = "inner block",
|
||||
["ac"] = "a class",
|
||||
["ic"] = "inner class",
|
||||
["af"] = "a function",
|
||||
["if"] = "inner function",
|
||||
["ak"] = "a comment",
|
||||
["aS"] = "a statement",
|
||||
}
|
||||
|
||||
wk.register(motions, { mode = "n" })
|
||||
wk.register(objects, { mode = "o" })
|
||||
128
modules/home/vim/after/plugin/mappings/unimpaired.lua
Normal file
128
modules/home/vim/after/plugin/mappings/unimpaired.lua
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
local wk = require("which-key")
|
||||
|
||||
local lsp = require("ambroisie.lsp")
|
||||
|
||||
local keys = {
|
||||
-- Edition and navigation mappins
|
||||
["["] = {
|
||||
name = "Previous",
|
||||
["<space>"] = "Insert blank line above",
|
||||
["<C-L>"] = "Previous location list file",
|
||||
["<C-Q>"] = "Previous quickfix list file",
|
||||
["<C-T>"] = "Previous tag in preview window",
|
||||
a = "Previous argument",
|
||||
A = "First argument",
|
||||
b = "Previous buffer",
|
||||
B = "First buffer",
|
||||
e = "Exchange previous line",
|
||||
f = "Previous file in directory",
|
||||
l = "Previous location list entry",
|
||||
L = "First Location list entry",
|
||||
n = "Previous conflict marker/diff hunk",
|
||||
p = "Paste line above",
|
||||
P = "Paste line above",
|
||||
q = "Previous quickfix list entry",
|
||||
Q = "First quickfix list entry",
|
||||
t = "Previous matching tag",
|
||||
T = "First matching tag",
|
||||
z = "Previous fold",
|
||||
-- Encoding
|
||||
C = "C string encode",
|
||||
u = "URL encode",
|
||||
x = "XML encode",
|
||||
y = "C string encode",
|
||||
-- Custom
|
||||
d = { lsp.goto_prev_diagnostic, "Previous diagnostic" },
|
||||
},
|
||||
["]"] = {
|
||||
name = "Next",
|
||||
["<space>"] = "Insert blank line below",
|
||||
["<C-L>"] = "Next location list file",
|
||||
["<C-Q>"] = "Next quickfix list file",
|
||||
["<C-T>"] = "Next tag in preview window",
|
||||
a = "Next argument",
|
||||
A = "Last argument",
|
||||
b = "Next buffer",
|
||||
B = "Last buffer",
|
||||
e = "Exchange next line",
|
||||
f = "Next file in directory",
|
||||
l = "Next location list entry",
|
||||
L = "Last Location list entry",
|
||||
n = "Next conflict marker/diff hunk",
|
||||
p = "Paste line below",
|
||||
P = "Paste line below",
|
||||
q = "Next quickfix list entry",
|
||||
Q = "Last quickfix list entry",
|
||||
t = "Next matching tag",
|
||||
T = "Last matching tag",
|
||||
z = "Next fold",
|
||||
-- Decoding
|
||||
C = "C string decode",
|
||||
u = "URL decode",
|
||||
x = "XML decode",
|
||||
y = "C string decode",
|
||||
-- Custom
|
||||
d = { lsp.goto_next_diagnostic, "Next diagnostic" },
|
||||
},
|
||||
|
||||
-- Option mappings
|
||||
["[o"] = {
|
||||
name = "Enable option",
|
||||
b = "Light background",
|
||||
c = "Cursor line",
|
||||
d = "Diff",
|
||||
f = { "<cmd>FormatEnable<CR>", "LSP Formatting" },
|
||||
h = "Search high-lighting",
|
||||
i = "Case insensitive search",
|
||||
l = "List mode",
|
||||
n = "Line numbers",
|
||||
r = "Relative line numbers",
|
||||
p = { "<cmd>lwindow<CR>", "Location list" },
|
||||
q = { "<cmd>cwindow<CR>", "Quickfix list" },
|
||||
u = "Cursor column",
|
||||
v = "Virtual editing",
|
||||
w = "Text wrapping",
|
||||
x = "Cursor line and column",
|
||||
z = "Spell checking",
|
||||
},
|
||||
["]o"] = {
|
||||
name = "Option off",
|
||||
b = "Light background",
|
||||
c = "Cursor line",
|
||||
d = "Diff",
|
||||
f = { "<cmd>FormatDisable<CR>", "LSP Formatting" },
|
||||
h = "Search high-lighting",
|
||||
i = "Case insensitive search",
|
||||
l = "List mode",
|
||||
n = "Line numbers",
|
||||
p = { "<cmd>lclose<CR>", "Location list" },
|
||||
q = { "<cmd>cclose<CR>", "Quickfix list" },
|
||||
r = "Relative line numbers",
|
||||
u = "Cursor column",
|
||||
v = "Virtual editing",
|
||||
w = "Text wrapping",
|
||||
x = "Cursor line and column",
|
||||
z = "Spell checking",
|
||||
},
|
||||
["yo"] = {
|
||||
name = "Option toggle",
|
||||
b = "Light background",
|
||||
c = "Cursor line",
|
||||
d = "Diff",
|
||||
f = { "<cmd>FormatToggle<CR>", "LSP Formatting" },
|
||||
h = "Search high-lighting",
|
||||
i = "Case insensitive search",
|
||||
l = "List mode",
|
||||
n = "Line numbers",
|
||||
p = { "<Plug>(qf_loc_toggle)", "Location list" },
|
||||
q = { "<Plug>(qf_qf_toggle)", "Quickfix list" },
|
||||
r = "Relative line numbers",
|
||||
u = "Cursor column",
|
||||
v = "Virtual editing",
|
||||
w = "Text wrapping",
|
||||
x = "Cursor line and column",
|
||||
z = "Spell checking",
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys)
|
||||
6
modules/home/vim/autoload/ftplugined.vim
Normal file
6
modules/home/vim/autoload/ftplugined.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
" Create the `b:undo_ftplugin` variable if it doesn't exist
|
||||
function! ftplugined#check_undo_ft()
|
||||
if !exists("b:undo_ftplugin")
|
||||
let b:undo_ftplugin=''
|
||||
endif
|
||||
endfunction
|
||||
114
modules/home/vim/default.nix
Normal file
114
modules/home/vim/default.nix
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.my.home.vim;
|
||||
configFiles =
|
||||
let
|
||||
toSource = directory: { source = ./. + "/${directory}"; };
|
||||
configureDirectory =
|
||||
name: lib.nameValuePair "nvim/${name}" (toSource name);
|
||||
linkDirectories =
|
||||
dirs: builtins.listToAttrs (map configureDirectory dirs);
|
||||
in
|
||||
linkDirectories [
|
||||
"after"
|
||||
"autoload"
|
||||
"ftdetect"
|
||||
"lua"
|
||||
"plugin"
|
||||
];
|
||||
in
|
||||
{
|
||||
options.my.home.vim = with lib; {
|
||||
enable = my.mkDisableOption "vim configuration";
|
||||
};
|
||||
|
||||
config.programs.neovim = lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
|
||||
# This is the best editor
|
||||
defaultEditor = true;
|
||||
|
||||
# All the aliases
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
# Theming
|
||||
gruvbox-nvim # Nice dark theme
|
||||
lualine-nvim # A lua-based status line
|
||||
lualine-lsp-progress # Show progress for LSP servers
|
||||
|
||||
# tpope essentials
|
||||
vim-commentary # Easy comments
|
||||
vim-eunuch # UNIX integrations
|
||||
vim-fugitive # A 'git' wrapper
|
||||
vim-git # Sane git syntax files
|
||||
vim-repeat # Enanche '.' for plugins
|
||||
vim-rsi # Readline mappings
|
||||
vim-unimpaired # Some ex command mappings
|
||||
vim-vinegar # Better netrw
|
||||
|
||||
# Languages
|
||||
rust-vim
|
||||
vim-beancount
|
||||
vim-jsonnet
|
||||
vim-nix
|
||||
vim-toml
|
||||
|
||||
# General enhancements
|
||||
vim-qf # Better quick-fix list
|
||||
nvim-osc52 # Send clipboard data through terminal escape for SSH
|
||||
|
||||
# Other wrappers
|
||||
git-messenger-vim # A simple blame window
|
||||
|
||||
# LSP and linting
|
||||
nvim-lspconfig # Easy LSP configuration
|
||||
lsp-format-nvim # Simplified formatting configuration
|
||||
lsp_lines-nvim # Show diagnostics *over* regions
|
||||
none-ls-nvim # LSP integration for linters and formatters
|
||||
nvim-treesitter.withAllGrammars # Better highlighting
|
||||
nvim-treesitter-textobjects # More textobjects
|
||||
nvim-ts-context-commentstring # Comment string in nested language blocks
|
||||
plenary-nvim # 'null-ls', 'telescope' dependency
|
||||
|
||||
# Completion
|
||||
luasnip # Snippet manager compatible with LSP
|
||||
friendly-snippets # LSP snippets collection
|
||||
nvim-cmp # Completion engine
|
||||
cmp-async-path # More responsive path completion
|
||||
cmp-buffer # Words from open buffers
|
||||
cmp-nvim-lsp # LSP suggestions
|
||||
cmp-nvim-lua # NeoVim lua API
|
||||
cmp-under-comparator # Sort items that start with '_' lower
|
||||
cmp_luasnip # Snippet suggestions from LuaSnip
|
||||
|
||||
# UX improvements
|
||||
dressing-nvim # Integrate native UI hooks with Telescope etc...
|
||||
gitsigns-nvim # Fast git UI integration
|
||||
nvim-surround # Deal with pairs, now in Lua
|
||||
telescope-fzf-native-nvim # Use 'fzf' fuzzy matching algorithm
|
||||
telescope-lsp-handlers-nvim # Use 'telescope' for various LSP actions
|
||||
telescope-nvim # Fuzzy finder interface
|
||||
which-key-nvim # Show available mappings
|
||||
];
|
||||
|
||||
extraConfig = builtins.readFile ./init.vim;
|
||||
|
||||
# Linters, formatters, etc...
|
||||
extraPackages = with pkgs; [
|
||||
# C/C++
|
||||
clang-tools
|
||||
|
||||
# Nix
|
||||
nixpkgs-fmt
|
||||
|
||||
# Shell
|
||||
shellcheck
|
||||
shfmt
|
||||
];
|
||||
};
|
||||
|
||||
config.xdg.configFile = lib.mkIf cfg.enable configFiles;
|
||||
}
|
||||
6
modules/home/vim/ftdetect/automake.lua
Normal file
6
modules/home/vim/ftdetect/automake.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Use Automake filetype for `local.am` files, explicit `set` to force override
|
||||
vim.filetype.add({
|
||||
filename = {
|
||||
["local.am"] = "automake",
|
||||
},
|
||||
})
|
||||
6
modules/home/vim/ftdetect/direnv.lua
Normal file
6
modules/home/vim/ftdetect/direnv.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Use bash filetype for `.envrc` files
|
||||
vim.filetype.add({
|
||||
filename = {
|
||||
[".envrc"] = "bash",
|
||||
},
|
||||
})
|
||||
6
modules/home/vim/ftdetect/kbuild.lua
Normal file
6
modules/home/vim/ftdetect/kbuild.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Kbuild is just a Makefile under a different name
|
||||
vim.filetype.add({
|
||||
filename = {
|
||||
["Kbuild"] = "make",
|
||||
},
|
||||
})
|
||||
6
modules/home/vim/ftdetect/kconfig.lua
Normal file
6
modules/home/vim/ftdetect/kconfig.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Mconfig is just Kconfig
|
||||
vim.filetype.add({
|
||||
filename = {
|
||||
["Mconfig"] = "kconfig",
|
||||
},
|
||||
})
|
||||
7
modules/home/vim/ftdetect/tiger.lua
Normal file
7
modules/home/vim/ftdetect/tiger.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- Use Tiger filetype for programs and header files
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
tig = "tiger",
|
||||
tih = "tiger",
|
||||
},
|
||||
})
|
||||
6
modules/home/vim/ftdetect/tikz.lua
Normal file
6
modules/home/vim/ftdetect/tikz.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Use LaTeX filetype for TikZ files
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
tikz = "tex",
|
||||
},
|
||||
})
|
||||
111
modules/home/vim/init.vim
Normal file
111
modules/home/vim/init.vim
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
" Basic configuraion {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Use UTF-8
|
||||
set encoding=utf-8
|
||||
set fileencodings=utf-8
|
||||
|
||||
" Allow unsaved buffers when switching windows
|
||||
set hidden
|
||||
|
||||
" Allow command completion in command-line
|
||||
set wildmenu
|
||||
|
||||
" Enable syntax high-lighting and file-type specific plugins
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
|
||||
" Map leader to space (needs the noremap trick to avoid moving the cursor)
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader=" "
|
||||
|
||||
" Map localleader to '!' (if I want to filter text, I use visual mode)
|
||||
let maplocalleader="!"
|
||||
" }}}
|
||||
|
||||
" Indentation configuration {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Use space by default
|
||||
set expandtab
|
||||
" Indent and align to 4 spaces by default
|
||||
set shiftwidth=4
|
||||
" -1 means the same as shiftwidth
|
||||
set softtabstop=-1
|
||||
" Always indent by multiples of shiftwidth
|
||||
set shiftround
|
||||
" You shouldn't change the default tab width of 8 characters
|
||||
set tabstop=8
|
||||
" }}}
|
||||
|
||||
" File parameters {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Disable backups, we have source control for that
|
||||
set nobackup
|
||||
" Disable swapfiles too
|
||||
set noswapfile
|
||||
" }}}
|
||||
|
||||
" UI and UX parameters {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set the minimal amount of lignes under and above the cursor for context
|
||||
set scrolloff=5
|
||||
" Always show status line
|
||||
set laststatus=2
|
||||
" Enable Doxygen highlighting
|
||||
let g:load_doxygen_syntax=1
|
||||
" Make backspace behave as expected
|
||||
set backspace=eol,indent,start
|
||||
" Use the visual bell instead of beeping
|
||||
set visualbell
|
||||
" Disable bell completely by resetting the visual bell's escape sequence
|
||||
set t_vb=
|
||||
|
||||
" Color the 80th column
|
||||
set colorcolumn=80
|
||||
" Show whitespace
|
||||
set list
|
||||
" Show a tab as an arrow, trailing spaces as ¤, non-breaking spaces as dots
|
||||
set listchars=tab:>─,trail:·,nbsp:¤
|
||||
|
||||
" Use patience diff
|
||||
set diffopt+=algorithm:patience
|
||||
" Align similar lines in each hunk
|
||||
set diffopt+=linematch:50
|
||||
|
||||
" Don't redraw when executing macros
|
||||
set lazyredraw
|
||||
|
||||
" Timeout quickly on shortcuts, I can't wait two seconds to delete in visual
|
||||
set timeoutlen=500
|
||||
|
||||
" Timeout quickly for CursorHold events (and also swap file)
|
||||
set updatetime=250
|
||||
|
||||
" Disable all mouse integrations
|
||||
set mouse=
|
||||
|
||||
" Set dark mode by default
|
||||
set background=dark
|
||||
|
||||
" 24 bit colors
|
||||
set termguicolors
|
||||
" Use my preferred colorscheme
|
||||
colorscheme gruvbox
|
||||
" }}}
|
||||
|
||||
" Search parameters {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Enable search high-lighting while the search is on-going
|
||||
set hlsearch
|
||||
" Ignore case on search
|
||||
set ignorecase
|
||||
" Ignore case unless there is an uppercase letter in the pattern
|
||||
set smartcase
|
||||
" }}}
|
||||
|
||||
" Project-local settings {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Securely read `.nvim.lua` or `.nvimrc`.
|
||||
set exrc
|
||||
" }}}
|
||||
|
||||
" vim: foldmethod=marker
|
||||
118
modules/home/vim/lua/ambroisie/lsp.lua
Normal file
118
modules/home/vim/lua/ambroisie/lsp.lua
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
local M = {}
|
||||
|
||||
-- Simplified LSP formatting configuration
|
||||
local lsp_format = require("lsp-format")
|
||||
|
||||
--- Move to the next/previous diagnostic, automatically showing the diagnostics
|
||||
--- float if necessary.
|
||||
--- @param forward whether to go forward or backwards
|
||||
local function goto_diagnostic(forward)
|
||||
vim.validate({
|
||||
forward = { forward, "boolean" },
|
||||
})
|
||||
|
||||
local opts = {
|
||||
float = false,
|
||||
}
|
||||
|
||||
-- Only show floating diagnostics if they are otherwise not displayed
|
||||
local config = vim.diagnostic.config()
|
||||
if not (config.virtual_text or config.virtual_lines) then
|
||||
opts.float = true
|
||||
end
|
||||
|
||||
if forward then
|
||||
vim.diagnostic.goto_next(opts)
|
||||
else
|
||||
vim.diagnostic.goto_prev(opts)
|
||||
end
|
||||
end
|
||||
|
||||
--- Move to the next diagnostic, automatically showing the diagnostics float if
|
||||
--- necessary.
|
||||
M.goto_next_diagnostic = function()
|
||||
goto_diagnostic(true)
|
||||
end
|
||||
|
||||
--- Move to the previous diagnostic, automatically showing the diagnostics float
|
||||
--- if necessary.
|
||||
M.goto_prev_diagnostic = function()
|
||||
goto_diagnostic(false)
|
||||
end
|
||||
|
||||
--- shared LSP configuration callback
|
||||
--- @param client native client configuration
|
||||
--- @param bufnr int? buffer number of the attched client
|
||||
M.on_attach = function(client, bufnr)
|
||||
-- Format on save
|
||||
lsp_format.on_attach(client, bufnr)
|
||||
|
||||
-- Mappings
|
||||
local wk = require("which-key")
|
||||
|
||||
local function list_workspace_folders()
|
||||
local utils = require("ambroisie.utils")
|
||||
utils.dump(vim.lsp.buf.list_workspace_folders())
|
||||
end
|
||||
|
||||
local function cycle_diagnostics_display()
|
||||
-- Cycle from:
|
||||
-- * nothing displayed
|
||||
-- * single diagnostic at the end of the line (`virtual_text`)
|
||||
-- * full diagnostics using virtual text (`virtual_lines`)
|
||||
local text = vim.diagnostic.config().virtual_text
|
||||
local lines = vim.diagnostic.config().virtual_lines
|
||||
|
||||
-- Text -> Lines transition
|
||||
if text then
|
||||
text = false
|
||||
lines = true
|
||||
-- Lines -> Nothing transition
|
||||
elseif lines then
|
||||
text = false
|
||||
lines = false
|
||||
-- Nothing -> Text transition
|
||||
else
|
||||
text = true
|
||||
lines = false
|
||||
end
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = text,
|
||||
virtual_lines = lines,
|
||||
})
|
||||
end
|
||||
|
||||
local function show_buffer_diagnostics()
|
||||
vim.diagnostic.open_float(nil, { scope = "buffer" })
|
||||
end
|
||||
|
||||
local keys = {
|
||||
K = { vim.lsp.buf.hover, "Show symbol information" },
|
||||
["<C-k>"] = { vim.lsp.buf.signature_help, "Show signature information" },
|
||||
["gd"] = { vim.lsp.buf.definition, "Go to definition" },
|
||||
["gD"] = { vim.lsp.buf.declaration, "Go to declaration" },
|
||||
["gi"] = { vim.lsp.buf.implementation, "Go to implementation" },
|
||||
["gr"] = { vim.lsp.buf.references, "List all references" },
|
||||
|
||||
["<leader>c"] = {
|
||||
name = "Code",
|
||||
a = { vim.lsp.buf.code_action, "Code actions" },
|
||||
d = { cycle_diagnostics_display, "Cycle diagnostics display" },
|
||||
D = { show_buffer_diagnostics, "Show buffer diagnostics" },
|
||||
r = { vim.lsp.buf.rename, "Rename symbol" },
|
||||
s = { vim.lsp.buf.signature_help, "Show signature" },
|
||||
t = { vim.lsp.buf.type_definition, "Go to type definition" },
|
||||
w = {
|
||||
name = "Workspace",
|
||||
a = { vim.lsp.buf.add_workspace_folder, "Add folder to workspace" },
|
||||
l = { list_workspace_folders, "List folders in workspace" },
|
||||
r = { vim.lsp.buf.remove_workspace_folder, "Remove folder from workspace" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys, { buffer = bufnr })
|
||||
end
|
||||
|
||||
return M
|
||||
57
modules/home/vim/lua/ambroisie/utils.lua
Normal file
57
modules/home/vim/lua/ambroisie/utils.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
local M = {}
|
||||
|
||||
--- pretty print lua object
|
||||
--- @param obj any object to pretty print
|
||||
M.dump = function(obj)
|
||||
print(vim.inspect(obj))
|
||||
end
|
||||
|
||||
--- checks if a given command is executable
|
||||
--- @param cmd string? command to check
|
||||
--- @return boolean executable
|
||||
M.is_executable = function(cmd)
|
||||
return cmd and vim.fn.executable(cmd) == 1
|
||||
end
|
||||
|
||||
--- return a function that checks if a given command is executable
|
||||
--- @param cmd string? command to check
|
||||
--- @return fun(cmd: string): boolean executable
|
||||
M.is_executable_condition = function(cmd)
|
||||
return function()
|
||||
return M.is_executable(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
--- whether or not we are currently in an SSH connection
|
||||
--- @return boolean ssh connection
|
||||
M.is_ssh = function()
|
||||
local variables = {
|
||||
"SSH_CONNECTION",
|
||||
"SSH_CLIENT",
|
||||
"SSH_TTY",
|
||||
}
|
||||
|
||||
for _, var in ipairs(variables) do
|
||||
if string.len(os.getenv(var) or "") ~= 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- list all active LSP clients for current buffer
|
||||
--- @param bufnr int? buffer number
|
||||
--- @return table all active LSP client names
|
||||
M.list_lsp_clients = function(bufnr)
|
||||
local clients = vim.lsp.buf_get_clients(bufnr)
|
||||
local names = {}
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
table.insert(names, client.name)
|
||||
end
|
||||
|
||||
return names
|
||||
end
|
||||
|
||||
return M
|
||||
9
modules/home/vim/plugin/abbreviations.lua
Normal file
9
modules/home/vim/plugin/abbreviations.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
local abbreviations = {
|
||||
-- A few things that are hard to write in ASCII
|
||||
["(R)"] = "©",
|
||||
["(TM)"] = "™",
|
||||
}
|
||||
|
||||
for text, result in pairs(abbreviations) do
|
||||
vim.cmd.abbreviate(text, result)
|
||||
end
|
||||
23
modules/home/vim/plugin/numbertoggle.lua
Normal file
23
modules/home/vim/plugin/numbertoggle.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- Show lines numbers
|
||||
vim.opt.number = true
|
||||
|
||||
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true })
|
||||
|
||||
-- Toggle numbers between relative and absolute when changing buffers
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "if &nu | setlocal rnu | endif",
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "if &nu | setlocal nornu | endif",
|
||||
})
|
||||
|
||||
-- Never show the sign column in a terminal buffer
|
||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "setlocal nonu nornu",
|
||||
})
|
||||
62
modules/home/vim/plugin/settings/completion.lua
Normal file
62
modules/home/vim/plugin/settings/completion.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
-- Show completion menu in all cases, and don't select anything
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
|
||||
local cmp = require("cmp")
|
||||
local cmp_under_comparator = require("cmp-under-comparator")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<Tab>"] = function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<S-Tab>"] = function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
|
||||
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-5),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(5),
|
||||
["<C-y>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
},
|
||||
view = {
|
||||
entries = "native",
|
||||
},
|
||||
sources = {
|
||||
{ name = "async_path", priority_weight = 110 },
|
||||
{ name = "nvim_lsp", priority_weight = 100 },
|
||||
{ name = "nvim_lua", priority_weight = 90 },
|
||||
{ name = "luasnip", priority_weight = 80 },
|
||||
{ name = "buffer", max_item_count = 5, priority_weight = 50 },
|
||||
},
|
||||
sorting = {
|
||||
priority_weight = 100,
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
cmp_under_comparator.under,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
})
|
||||
6
modules/home/vim/plugin/settings/dressing.lua
Normal file
6
modules/home/vim/plugin/settings/dressing.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local dressing = require("dressing")
|
||||
|
||||
dressing.setup({
|
||||
-- Use a relative prompt size
|
||||
prefer_width = 0.4,
|
||||
})
|
||||
5
modules/home/vim/plugin/settings/fastfold.lua
Normal file
5
modules/home/vim/plugin/settings/fastfold.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- Intercept all fold commands
|
||||
-- stylua: ignore
|
||||
vim.g.fastfold_fold_command_suffixes = {
|
||||
"x", "X", "a", "A", "o", "O", "c", "C", "r", "R", "m", "M", "i", "n", "N",
|
||||
}
|
||||
3
modules/home/vim/plugin/settings/formatting.lua
Normal file
3
modules/home/vim/plugin/settings/formatting.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local lsp_format = require("lsp-format")
|
||||
|
||||
lsp_format.setup({})
|
||||
58
modules/home/vim/plugin/settings/git.lua
Normal file
58
modules/home/vim/plugin/settings/git.lua
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
local gitsigns = require("gitsigns")
|
||||
local wk = require("which-key")
|
||||
|
||||
gitsigns.setup({
|
||||
current_line_blame_opts = {
|
||||
-- Show the blame quickly
|
||||
delay = 100,
|
||||
},
|
||||
})
|
||||
|
||||
local keys = {
|
||||
-- Navigation
|
||||
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
|
||||
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
|
||||
|
||||
-- Commands
|
||||
["<leader>g"] = {
|
||||
name = "Git",
|
||||
-- Actions
|
||||
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" },
|
||||
d = { gitsigns.diffthis, "Diff buffer" },
|
||||
-- stylua: ignore
|
||||
D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" },
|
||||
g = { "<cmd>Git<CR>", "Git status" },
|
||||
h = { gitsigns.toggle_deleted, "Show deleted hunks" },
|
||||
L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" },
|
||||
m = { "<Plug>(git-messenger)", "Current line blame" },
|
||||
p = { gitsigns.preview_hunk, "Preview hunk" },
|
||||
r = { gitsigns.reset_hunk, "Restore hunk" },
|
||||
R = { gitsigns.reset_buffer, "Restore buffer" },
|
||||
s = { gitsigns.stage_hunk, "Stage hunk" },
|
||||
S = { gitsigns.stage_buffer, "Stage buffer" },
|
||||
u = { gitsigns.undo_stage_hunk, "Undo stage hunk" },
|
||||
["["] = { gitsigns.prev_hunk, "Previous hunk" },
|
||||
["]"] = { gitsigns.next_hunk, "Next hunk" },
|
||||
},
|
||||
}
|
||||
|
||||
local objects = {
|
||||
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
||||
}
|
||||
|
||||
local visual = {
|
||||
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
||||
|
||||
-- Only the actual command can make use of the visual selection...
|
||||
["<leader>g"] = {
|
||||
name = "Git",
|
||||
p = { ":Gitsigns preview_hunk<CR>", "Preview selection" },
|
||||
r = { ":Gitsigns reset_hunk<CR>", "Restore selection" },
|
||||
s = { ":Gitsigns stage_hunk<CR>", "Stage selection" },
|
||||
u = { ":Gitsigns undo_stage_hunk<CR>", "Undo stage selection" },
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys, { buffer = bufnr })
|
||||
wk.register(objects, { buffer = bufnr, mode = "o" })
|
||||
wk.register(visual, { buffer = bufnr, mode = "x" })
|
||||
3
modules/home/vim/plugin/settings/lsp-lines.lua
Normal file
3
modules/home/vim/plugin/settings/lsp-lines.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local lsp_lines = require("lsp_lines")
|
||||
|
||||
lsp_lines.setup()
|
||||
61
modules/home/vim/plugin/settings/lspconfig.lua
Normal file
61
modules/home/vim/plugin/settings/lspconfig.lua
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
local lsp = require("ambroisie.lsp")
|
||||
local utils = require("ambroisie.utils")
|
||||
|
||||
-- Diagnostics
|
||||
vim.diagnostic.config({
|
||||
-- Disable virtual test next to affected regions
|
||||
virtual_text = false,
|
||||
-- Also disable virtual diagnostics under the affected regions
|
||||
virtual_lines = false,
|
||||
-- Show diagnostics signs
|
||||
signs = true,
|
||||
-- Underline offending regions
|
||||
underline = true,
|
||||
-- Do not bother me in the middle of insertion
|
||||
update_in_insert = false,
|
||||
-- Show highest severity first
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Inform servers we are able to do completion, snippets, etc...
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- C/C++
|
||||
if utils.is_executable("clangd") then
|
||||
lspconfig.clangd.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
end
|
||||
|
||||
-- Nix
|
||||
if utils.is_executable("nil") then
|
||||
lspconfig.nil_ls.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
end
|
||||
|
||||
if utils.is_executable("rnix-lsp") then
|
||||
lspconfig.rnix.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
end
|
||||
|
||||
-- Python
|
||||
if utils.is_executable("pyright") then
|
||||
lspconfig.pyright.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
end
|
||||
|
||||
-- Rust
|
||||
if utils.is_executable("rust-analyzer") then
|
||||
lspconfig.rust_analyzer.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
end
|
||||
61
modules/home/vim/plugin/settings/lualine.lua
Normal file
61
modules/home/vim/plugin/settings/lualine.lua
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
local lualine = require("lualine")
|
||||
local utils = require("ambroisie.utils")
|
||||
|
||||
local function list_spell_languages()
|
||||
if not vim.opt.spell:get() then
|
||||
return ""
|
||||
end
|
||||
|
||||
return table.concat(vim.opt.spelllang:get(), ", ")
|
||||
end
|
||||
|
||||
local function list_lsp_clients()
|
||||
local client_names = utils.list_lsp_clients()
|
||||
|
||||
if #client_names == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
return "[ " .. table.concat(client_names, " ") .. " ]"
|
||||
end
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
section_separators = "",
|
||||
component_separators = "|",
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
{ "mode" },
|
||||
},
|
||||
lualine_b = {
|
||||
{ "FugitiveHead" },
|
||||
{ "filename", symbols = { readonly = "🔒" } },
|
||||
},
|
||||
lualine_c = {
|
||||
{ list_spell_languages },
|
||||
{ "lsp_progress" },
|
||||
},
|
||||
lualine_x = {
|
||||
{ list_lsp_clients },
|
||||
{
|
||||
"diagnostics",
|
||||
-- Only use the diagnostics API
|
||||
sources = { "nvim_diagnostic" },
|
||||
},
|
||||
},
|
||||
lualine_y = {
|
||||
{ "fileformat" },
|
||||
{ "encoding" },
|
||||
{ "filetype" },
|
||||
},
|
||||
lualine_z = {
|
||||
"location",
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
"fugitive",
|
||||
"quickfix",
|
||||
},
|
||||
})
|
||||
1
modules/home/vim/plugin/settings/luasnip.lua
Normal file
1
modules/home/vim/plugin/settings/luasnip.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
138
modules/home/vim/plugin/settings/null-ls.lua
Normal file
138
modules/home/vim/plugin/settings/null-ls.lua
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
local null_ls = require("null-ls")
|
||||
local lsp = require("ambroisie.lsp")
|
||||
local utils = require("ambroisie.utils")
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = lsp.on_attach,
|
||||
})
|
||||
|
||||
-- Bazel
|
||||
null_ls.register({
|
||||
null_ls.builtins.diagnostics.buildifier.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("buildifier"),
|
||||
}),
|
||||
null_ls.builtins.formatting.buildifier.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("buildifier"),
|
||||
}),
|
||||
})
|
||||
|
||||
-- C, C++
|
||||
null_ls.register({
|
||||
null_ls.builtins.formatting.clang_format.with({
|
||||
-- Only used if available, but prefer clangd formatting if available
|
||||
condition = function()
|
||||
return utils.is_executable("clang-format") and not utils.is_executable("clangd")
|
||||
end,
|
||||
}),
|
||||
})
|
||||
|
||||
-- Haskell
|
||||
null_ls.register({
|
||||
null_ls.builtins.formatting.brittany.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("brittany"),
|
||||
}),
|
||||
})
|
||||
|
||||
-- Nix
|
||||
null_ls.register({
|
||||
null_ls.builtins.formatting.nixpkgs_fmt.with({
|
||||
-- Only used if available, but prefer rnix if available
|
||||
condition = function()
|
||||
return utils.is_executable("nixpkgs-fmt")
|
||||
and not utils.is_executable("rnix-lsp")
|
||||
and not utils.is_executable("nil")
|
||||
end,
|
||||
}),
|
||||
})
|
||||
|
||||
-- Python
|
||||
null_ls.register({
|
||||
null_ls.builtins.diagnostics.flake8.with({
|
||||
-- Only used if available, but prefer pflake8 if available
|
||||
condition = function()
|
||||
return utils.is_executable("flake8") and not utils.is_executable("pflake8")
|
||||
end,
|
||||
}),
|
||||
null_ls.builtins.diagnostics.pyproject_flake8.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("pflake8"),
|
||||
}),
|
||||
null_ls.builtins.diagnostics.mypy.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("mypy"),
|
||||
}),
|
||||
null_ls.builtins.diagnostics.pylint.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("pylint"),
|
||||
}),
|
||||
null_ls.builtins.formatting.black.with({
|
||||
extra_args = { "--fast" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("black"),
|
||||
}),
|
||||
null_ls.builtins.formatting.isort.with({
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("isort"),
|
||||
}),
|
||||
})
|
||||
|
||||
-- Shell (non-POSIX)
|
||||
null_ls.register({
|
||||
null_ls.builtins.code_actions.shellcheck.with({
|
||||
-- Restrict to bash and zsh
|
||||
filetypes = { "bash", "zsh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shellcheck"),
|
||||
}),
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
-- Show error code in message
|
||||
diagnostics_format = "[#{c}] #{m}",
|
||||
-- Require explicit empty string test, use bash dialect
|
||||
extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" },
|
||||
-- Restrict to bash and zsh
|
||||
filetypes = { "bash", "zsh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shellcheck"),
|
||||
}),
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
-- Indent with 4 spaces, simplify the code, indent switch cases,
|
||||
-- add space after redirection, use bash dialect
|
||||
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" },
|
||||
-- Restrict to bash and zsh
|
||||
filetypes = { "bash", "zsh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shfmt"),
|
||||
}),
|
||||
})
|
||||
|
||||
-- Shell (POSIX)
|
||||
null_ls.register({
|
||||
null_ls.builtins.code_actions.shellcheck.with({
|
||||
-- Restrict to POSIX sh
|
||||
filetypes = { "sh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shellcheck"),
|
||||
}),
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
-- Show error code in message
|
||||
diagnostics_format = "[#{c}] #{m}",
|
||||
-- Require explicit empty string test
|
||||
extra_args = { "-o", "avoid-nullary-conditions" },
|
||||
-- Restrict to POSIX sh
|
||||
filetypes = { "sh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shellcheck"),
|
||||
}),
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
-- Indent with 4 spaces, simplify the code, indent switch cases,
|
||||
-- add space after redirection, use POSIX
|
||||
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "posix" },
|
||||
-- Restrict to POSIX sh
|
||||
filetypes = { "sh" },
|
||||
-- Only used if available
|
||||
condition = utils.is_executable_condition("shfmt"),
|
||||
}),
|
||||
})
|
||||
17
modules/home/vim/plugin/settings/ssh.lua
Normal file
17
modules/home/vim/plugin/settings/ssh.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
if not require("ambroisie.utils").is_ssh() then
|
||||
return
|
||||
end
|
||||
|
||||
local function copy(lines, _)
|
||||
require("osc52").copy(table.concat(lines, "\n"))
|
||||
end
|
||||
|
||||
local function paste()
|
||||
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
|
||||
end
|
||||
|
||||
vim.g.clipboard = {
|
||||
name = "osc52",
|
||||
copy = { ["+"] = copy, ["*"] = copy },
|
||||
paste = { ["+"] = paste, ["*"] = paste },
|
||||
}
|
||||
3
modules/home/vim/plugin/settings/surround.lua
Normal file
3
modules/home/vim/plugin/settings/surround.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
require("nvim-surround").setup({
|
||||
-- No configuration at the moment
|
||||
})
|
||||
24
modules/home/vim/plugin/settings/telescope.lua
Normal file
24
modules/home/vim/plugin/settings/telescope.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local telescope = require("telescope")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-h>"] = "which_key",
|
||||
-- I want the normal readline mappings rather than scrolling
|
||||
["<C-u>"] = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("lsp_handlers")
|
||||
56
modules/home/vim/plugin/settings/tree-sitter.lua
Normal file
56
modules/home/vim/plugin/settings/tree-sitter.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
local ts_config = require("nvim-treesitter.configs")
|
||||
ts_config.setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- Avoid duplicate highlighting
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
-- Jump to matching text objects
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["aa"] = "@parameter.outer",
|
||||
["ia"] = "@parameter.inner",
|
||||
["ab"] = "@block.outer",
|
||||
["ib"] = "@block.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ak"] = "@comment.outer",
|
||||
["aS"] = "@statement.outer",
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
-- Add to jump list
|
||||
set_jumps = true,
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]S"] = "@statement.outer",
|
||||
["]]"] = "@class.outer",
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]["] = "@class.outer",
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[S"] = "@statement.outer",
|
||||
["[["] = "@class.outer",
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[]"] = "@class.outer",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
2
modules/home/vim/plugin/settings/which-key.lua
Normal file
2
modules/home/vim/plugin/settings/which-key.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
local wk = require("which-key")
|
||||
wk.setup()
|
||||
20
modules/home/vim/plugin/signtoggle.lua
Normal file
20
modules/home/vim/plugin/signtoggle.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
|
||||
|
||||
-- Only show sign column for the currently focused buffer
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=yes",
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=yes",
|
||||
})
|
||||
|
||||
-- Never show the sign column in a terminal buffer
|
||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=no",
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue