Compare commits

..

4 commits

Author SHA1 Message Date
teutat3s 7ccefe0601
terminal-life: reduce nvim config, switch to telescope
Co-authored-by: b12f <b12f@noreply.git.pub.solar>
2024-08-19 10:18:12 +02:00
teutat3s d8f1b24935
nix: use lix multiline log format 2024-08-19 10:15:42 +02:00
teutat3s 1395a620b4
style: avoid final newlines in secrets/*
format using nixfmt-rfc-style
2024-08-19 10:14:21 +02:00
teutat3s 3a61d04b02
flake.lock: Update
Flake lock file updates:

• Updated input 'lix-module':
    '622a2253a0.tar.gz?narHash=sha256-zNW/rqNJwhq2lYmQf19wJerRuNimjhxHKmzrWWFJYts%3D' (2024-08-13)
  → '622a2253a0.tar.gz?narHash=sha256-zNW/rqNJwhq2lYmQf19wJerRuNimjhxHKmzrWWFJYts%3D&rev=622a2253a071a1fb97a4d3c8103a91114acc1140' (2024-08-13)
• Updated input 'nix-darwin':
    'github:lnl7/nix-darwin/91010a5613ffd7ee23ee9263213157a1c422b705' (2024-08-06)
  → 'github:lnl7/nix-darwin/076b9a905af8a52b866c8db068d6da475839d97b' (2024-08-17)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/a731b45590a5169542990c36ffcde6cebd9a3356' (2024-08-11)
  → 'github:nixos/nixpkgs/c42fcfbdfeae23e68fc520f9182dde9f38ad1890' (2024-08-17)
• Updated input 'unstable':
    'github:nixos/nixpkgs/a58bc8ad779655e790115244571758e8de055e3d' (2024-08-11)
  → 'github:nixos/nixpkgs/c3aa7b8938b17aebd2deecf7be0636000d62a2b9' (2024-08-14)
• Updated input 'wayland-pipewire-idle-inhibit':
    'github:rafaelrc7/wayland-pipewire-idle-inhibit/01f15357c38590662ae44606b63cc2bb3d1c5938' (2024-07-20)
  → 'github:rafaelrc7/wayland-pipewire-idle-inhibit/ab6c30cdf1cfbabd65e1a5a30f0dc94d1114bb45' (2024-08-19)
2024-08-19 09:38:05 +02:00
15 changed files with 341 additions and 532 deletions

View file

@ -20,6 +20,14 @@ indent_style = unset
indent_size = unset indent_size = unset
[{.*,secrets}/**] [{.*,secrets}/**]
end_of_line = false
insert_final_newline = false
trim_trailing_whitespace = unset
charset = unset
indent_style = unset
indent_size = unset
[*.rom]
end_of_line = unset end_of_line = unset
insert_final_newline = unset insert_final_newline = unset
trim_trailing_whitespace = unset trim_trailing_whitespace = unset

View file

@ -248,7 +248,7 @@
"narHash": "sha256-zNW/rqNJwhq2lYmQf19wJerRuNimjhxHKmzrWWFJYts=", "narHash": "sha256-zNW/rqNJwhq2lYmQf19wJerRuNimjhxHKmzrWWFJYts=",
"rev": "622a2253a071a1fb97a4d3c8103a91114acc1140", "rev": "622a2253a071a1fb97a4d3c8103a91114acc1140",
"type": "tarball", "type": "tarball",
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/622a2253a071a1fb97a4d3c8103a91114acc1140.tar.gz" "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/622a2253a071a1fb97a4d3c8103a91114acc1140.tar.gz?rev=622a2253a071a1fb97a4d3c8103a91114acc1140"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
@ -262,11 +262,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1722924007, "lastModified": 1723859949,
"narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=", "narHash": "sha256-kiaGz4deGYKMjJPOji/JVvSP/eTefrIA3rAjOnOpXl4=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "91010a5613ffd7ee23ee9263213157a1c422b705", "rev": "076b9a905af8a52b866c8db068d6da475839d97b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -324,11 +324,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1723400035, "lastModified": 1723938990,
"narHash": "sha256-WoKZDlBEdMhP+hjquBAh0BhUJbcH2+U8g2mHOr1mv8I=", "narHash": "sha256-9tUadhnZQbWIiYVXH8ncfGXGvkNq3Hag4RCBEMUk7MI=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a731b45590a5169542990c36ffcde6cebd9a3356", "rev": "c42fcfbdfeae23e68fc520f9182dde9f38ad1890",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -466,13 +466,13 @@
"rev": "0d039dcf06afb8cbddd7ac54bae4d0d185f3e88e", "rev": "0d039dcf06afb8cbddd7ac54bae4d0d185f3e88e",
"revCount": 85, "revCount": 85,
"type": "git", "type": "git",
"url": "https://git.pub.solar/pub-solar/infra-vintage?dir=vmtools" "url": "https://git.pub.solar/pub-solar/infra-vintage"
}, },
"original": { "original": {
"dir": "vmtools", "dir": "vmtools",
"ref": "main", "ref": "main",
"type": "git", "type": "git",
"url": "https://git.pub.solar/pub-solar/infra-vintage?dir=vmtools" "url": "https://git.pub.solar/pub-solar/infra-vintage"
} }
}, },
"tritonshell": { "tritonshell": {
@ -500,11 +500,11 @@
}, },
"unstable": { "unstable": {
"locked": { "locked": {
"lastModified": 1723362943, "lastModified": 1723637854,
"narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=", "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a58bc8ad779655e790115244571758e8de055e3d", "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -543,11 +543,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1721447721, "lastModified": 1724040047,
"narHash": "sha256-vcDaLwe4NxFvo6JPMWUGOpDM9ztrAm9mFYI8UGfMhmg=", "narHash": "sha256-8oVTexYGQWyaAVJedrp4kIQ7VjBR47l65eByZr7oghg=",
"owner": "rafaelrc7", "owner": "rafaelrc7",
"repo": "wayland-pipewire-idle-inhibit", "repo": "wayland-pipewire-idle-inhibit",
"rev": "01f15357c38590662ae44606b63cc2bb3d1c5938", "rev": "ab6c30cdf1cfbabd65e1a5a30f0dc94d1114bb45",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -102,6 +102,8 @@
}; };
flake = { flake = {
formatter."x86_64-linux" = inputs.unstable.legacyPackages."x86_64-linux".nixfmt-rfc-style;
deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations { deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations {
#example = { #example = {
# hostname = "example.com:22"; # hostname = "example.com:22";

View file

@ -17,22 +17,6 @@ in {
signal-desktop signal-desktop
tdesktop tdesktop
element-desktop element-desktop
binutils
ripgrep
jq
# Nix specific utilities
alejandra
manix
nix-init
nix-inspect
nix-output-monitor
nix-tree
nvd
nixpkgs-review
nix-update
nix-search-cli
]; ];
fonts = { fonts = {

View file

@ -120,5 +120,6 @@ in {
myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
nnn = "nnn -d -e -H -r"; nnn = "nnn -d -e -H -r";
tmate = ''tmate -f "''${XDG_CONFIG_HOME}/tmate/tmate.conf"''; tmate = ''tmate -f "''${XDG_CONFIG_HOME}/tmate/tmate.conf"'';
nix = "nix --log-format multiline";
}; };
} }

View file

@ -27,7 +27,6 @@ in {
programs.nix-index.enableBashIntegration = false; programs.nix-index.enableBashIntegration = false;
users.users."${psCfg.user.name}".packages = with pkgs; [ users.users."${psCfg.user.name}".packages = with pkgs; [
ack
asciinema asciinema
bat bat
blesh blesh
@ -43,10 +42,23 @@ in {
]; ];
})) }))
powerline powerline
ripgrep
screen screen
silver-searcher
watson watson
]; ] ++ (if cfg.full then [
binutils
jq
# Nix specific utilities
manix
nix-index
nix-tree
nix-inspect
nvd
nixpkgs-review
nix-update
nix-search-cli
] else []);
# Get completion for system packages # Get completion for system packages
# https://nix-community.github.io/home-manager/options.xhtml#opt-programs.bash.enableCompletion # https://nix-community.github.io/home-manager/options.xhtml#opt-programs.bash.enableCompletion
@ -89,6 +101,7 @@ in {
inherit pkgs; inherit pkgs;
inherit lib; inherit lib;
}; };
# Ensure nvim backup directory gets created # Ensure nvim backup directory gets created
# Workaround for E510: Can't make backup file (add ! to override) # Workaround for E510: Can't make backup file (add ! to override)
xdg.dataFile."nvim/backup/.keep".text = ""; xdg.dataFile."nvim/backup/.keep".text = "";

View file

@ -0,0 +1,48 @@
lua <<EOF
local luasnip = require 'luasnip'
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}
EOF

View file

@ -7,8 +7,6 @@
psCfg = config.pub-solar; psCfg = config.pub-solar;
cfg = config.pub-solar.terminal-life; cfg = config.pub-solar.terminal-life;
xdg = config.home-manager.users."${psCfg.user.name}".xdg; xdg = config.home-manager.users."${psCfg.user.name}".xdg;
preview-file = pkgs.writeShellScriptBin "preview-file" (import ./preview-file.nix pkgs);
in { in {
enable = true; enable = true;
@ -20,101 +18,35 @@ in {
withRuby = true; withRuby = true;
withPython3 = true; withPython3 = true;
extraPackages = with pkgs; extraPackages = with pkgs; [
lib.mkIf (cfg.full) [ ripgrep
ansible-language-server
ccls
gopls
nixd nixd
nodejs
nodePackages.bash-language-server
nodePackages.dockerfile-language-server-nodejs
nodePackages.svelte-language-server
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.vim-language-server
nodePackages.vue-language-server
nodePackages.vscode-langservers-extracted
nodePackages.yaml-language-server
python3Packages.python-lsp-server
python3Full
rust-analyzer
shellcheck
solargraph
terraform-ls
universal-ctags universal-ctags
# ansible-language-server
# clang-tools
# gopls
# nodePackages.bash-language-server
# nodePackages.svelte-language-server
# nodePackages.typescript
# nodePackages.typescript-language-server
# nodePackages.vue-language-server
# nodePackages.vscode-langservers-extracted
# nginx-language-server
# lua-language-server
# cmake-language-server
# vim-language-server
# yaml-language-server
# python3Packages.python-lsp-server
# nodePackages.dockerfile-language-server-nodejs
# docker-compose-language-service
# rust-analyzer
# cargo
# solargraph
# terraform-ls
# python3Full
]; ];
plugins = with pkgs.vimPlugins; lib.mkIf cfg.full [ plugins = with pkgs.vimPlugins; [
(pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [
p.ini
p.json
p.json5
p.markdown
p.nix
p.toml
p.yaml
p.css
p.graphql
p.html
p.javascript
p.scss
p.tsx
p.typescript
p.vue
p.c
p.cpp
p.go
p.gomod
p.gosum
p.haskell
p.lua
p.php
p.python
p.ruby
p.rust
p.vim
p.vimdoc
p.passwd
p.sql
p.diff
p.gitcommit
p.gitignore
p.git_config
p.gitattributes
p.git_rebase
p.bash
p.dockerfile
p.make
p.ninja
p.terraform
]))
# Dependencies for nvim-lspconfig
nvim-cmp
cmp-nvim-lsp
cmp_luasnip
luasnip
# Quickstart configs for neovim LSP
lsp_extensions-nvim
nvim-lspconfig
# Collaborative editing in Neovim using built-in capabilities
instant-nvim-nvfetcher
# Search functionality behind :Ack
ack-vim
# Go development
vim-go
# The status bar in the bottom of the screen with the mode indication and file location # The status bar in the bottom of the screen with the mode indication and file location
vim-airline vim-airline
@ -127,18 +59,9 @@ in {
# Highlight characters when using f, F, t, and T # Highlight characters when using f, F, t, and T
quick-scope quick-scope
# Get sudo in vim; :SudaWrite <optional filename>
vim-suda
# Undo history etc. per project # Undo history etc. per project
vim-workspace-nvfetcher vim-workspace-nvfetcher
# JSON schemas
SchemaStore-nvim
# Work with tags files
vim-gutentags
# Neovim colorschemes / themes # Neovim colorschemes / themes
sonokai sonokai
vim-hybrid-material vim-hybrid-material
@ -155,9 +78,10 @@ in {
# Ease your git workflow within Vim # Ease your git workflow within Vim
vimagit-nvfetcher vimagit-nvfetcher
# FZF fuzzy finder # Telescope fuzzy finder
fzf-vim telescope-nvim
fzfWrapper telescope-fzf-native-nvim
# Make the yanked region apparent # Make the yanked region apparent
vim-highlightedyank vim-highlightedyank
@ -166,22 +90,39 @@ in {
# Unload, delete or wipe a buffer without closing the window # Unload, delete or wipe a buffer without closing the window
vim-bufkill vim-bufkill
# Defaults everyone can agree on # Defaults everyone can agree on
vim-sensible vim-sensible
# emmet for vim: http://emmet.io/ # Single tabpage interface for easily cycling through diffs for all modified files
emmet-vim diffview-nvim
# Work with tags files
vim-gutentags
] ++ (if cfg.full then [
nvim-treesitter.withAllGrammars
# Dependencies for nvim-lspconfig
nvim-cmp
cmp-nvim-lsp
cmp_luasnip
luasnip
# Quickstart configs for neovim LSP
lsp_extensions-nvim
nvim-lspconfig
# Collaborative editing in Neovim using built-in capabilities
instant-nvim-nvfetcher
# Caddyfile syntax support for Vim # Caddyfile syntax support for Vim
vim-caddyfile-nvfetcher vim-caddyfile-nvfetcher
# Fix TOFU hashes when writing nix derivations without leaving neovim # JSON schemas
vim-nixhash SchemaStore-nvim
] else []);
# Single tabpage interface for easily cycling through diffs for all modified files extraConfig = builtins.concatStringsSep "\n" ([
diffview-nvim
];
extraConfig = builtins.concatStringsSep "\n" [
'' ''
" Persistent undo " Persistent undo
set undofile set undofile
@ -194,13 +135,9 @@ in {
(builtins.readFile ./plugins.vim) (builtins.readFile ./plugins.vim)
(builtins.readFile ./clipboard.vim) (builtins.readFile ./clipboard.vim)
(builtins.readFile ./ui.vim) (builtins.readFile ./ui.vim)
(builtins.readFile ./quickfixopenall.vim)
(builtins.readFile ./lsp.vim)
(builtins.readFile ./lastplace.lua) (builtins.readFile ./lastplace.lua)
'' ] ++ (if cfg.full then [
" fzf with file preview (builtins.readFile ./lsp.vim)
command! -bang -nargs=? -complete=dir Files (builtins.readFile ./cmp.vim)
\ call fzf#vim#files(<q-args>, { 'options': ['--keep-right', '--cycle', '--layout', 'reverse', '--preview', '${preview-file}/bin/preview-file {}'] }, <bang>0) ] else []));
''
];
} }

View file

@ -77,9 +77,6 @@ nmap <leader>j :bprevious<CR>
" This replicates the idea of closing a tab " This replicates the idea of closing a tab
nmap <leader>q :bp <BAR> bd #<CR> nmap <leader>q :bp <BAR> bd #<CR>
" Show all open buffers and their status
nmap <leader>bl :ls<CR>
"
" Move to the next tab " Move to the next tab
nmap <leader>tl :tabnext<CR> nmap <leader>tl :tabnext<CR>
@ -89,23 +86,5 @@ nmap <leader>tj :tabprevious<CR>
" Close the current tab " Close the current tab
nmap <leader>tq :tabclose<CR> nmap <leader>tq :tabclose<CR>
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
nmap <c-p> :Files<CR>
imap <c-p> <ESC>:Files<CR>
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Clear quickfix shortcut " Clear quickfix shortcut
nmap <Leader>c :ccl<CR> nmap <Leader>c :ccl<CR>
nmap - :NnnPicker %<CR>
nmap <leader>n :NnnPicker %<CR>
nmap <leader>N :NnnPicker<CR>

View file

@ -1,41 +1,28 @@
" Set completeopt to have a better completion experience
" :help completeopt
" menuone: popup even when there's only one match
" noinsert: Do not insert text until a selection is made
" noselect: Do not select, force user to select one from the menu
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
function AddTemplate(tmpl_file)
exe "0read " . a:tmpl_file
set nomodified
6
endfunction
autocmd BufNewFile shell.nix call AddTemplate("$XDG_DATA_HOME/nvim/templates/shell.nix.tmpl")
" Configure neovim 0.6+ experimental LSPs " Configure neovim 0.6+ experimental LSPs
" https://github.com/neovim/nvim-lspconfig " https://github.com/neovim/nvim-lspconfig
" https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md " https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
" https://github.com/neovim/nvim-lspconfig/wiki/UI-Customization " https://github.com/neovim/nvim-lspconfig/wiki/UI-Customization
" https://gitlab.com/Iron_E/dotfiles/-/blob/master/.config/nvim/lua/_config/plugin/nvim_lsp.lua " https://gitlab.com/Iron_E/dotfiles/-/blob/master/.config/nvim/lua/_config/plugin/nvim_lsp.lua
lua <<EOF lua <<EOF
local nvim_lsp = require('lspconfig')
-- Mappings (global) -- Set completeopt to have a better completion experience
-- See `:help vim.diagnostic.*` for documentation on any of the below functions vim.o.completeopt = 'menuone,noselect,noinsert'
local opts = { noremap=true, silent=true } vim.o.shortmess = vim.o.shortmess .. 'c'
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts) vim.o.signcolumn = 'yes:2'
vim.api.nvim_set_keymap('n', 'g[', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', 'g]', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>dq', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
-- Use an on_attach function to only map the following keys local lspconfig = require('lspconfig')
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) -- Mappings (global)
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', 'g[', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', 'g]', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>dq', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
local on_attach = function(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')
@ -43,8 +30,9 @@ lua <<EOF
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
@ -52,7 +40,6 @@ lua <<EOF
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
-- Show diagnostic popup on cursor hold -- Show diagnostic popup on cursor hold
vim.api.nvim_create_autocmd("CursorHold", { vim.api.nvim_create_autocmd("CursorHold", {
@ -70,189 +57,93 @@ lua <<EOF
end end
}) })
end
local lspconfig = require 'lspconfig'
-- Add additional capabilities supported by nvim-cmp
local CAPABILITIES = require('cmp_nvim_lsp').default_capabilities()
--- Event handlers
local HANDLERS = {
-- TODO: replace with vim.lsp.protocol.Methods
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, FLOAT_CONFIG),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, FLOAT_CONFIG),
}
-- vscode HTML lsp needs this https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html
CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
local function setup(lsp, config)
if config == nil then
config = {}
end end
-- Add additional capabilities supported by nvim-cmp config.capabilities = CAPABILITIES
local capabilities = require('cmp_nvim_lsp').default_capabilities() config.handlers = HANDLERS
-- vscode HTML lsp needs this https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html config.on_attach = on_attach
capabilities.textDocument.completion.completionItem.snippetSupport = true lspconfig[lsp].setup(config)
end
-- vscode HTML lsp needs this https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html setup('nixd')
capabilities.textDocument.completion.completionItem.snippetSupport = true setup('bashls')
setup('clangd')
local use_denols_for_typescript = not(os.getenv('NVIM_USE_DENOLS') == nil) setup('cssls')
setup('eslint')
for lsp_key, lsp_settings in pairs({ setup('tsserver')
'ansiblels', ---------------------------- Ansible setup('denols')
'bashls', ------------------------------- Bash setup('vuels')
'ccls', --------------------------------- C / C++ / Objective-C setup('svelte')
'cssls', -------------------------------- CSS / SCSS / LESS setup('html')
'dockerls', ----------------------------- Docker setup('yamlls')
['gopls'] = { --------------------------- Go setup('jsonls', {
['settings'] = { json = {
['gopls'] = { schemas = require('schemastore').json.schemas(),
['analyses'] = { validate = {
['unusedparams'] = true, enable = true
},
['staticcheck'] = true
},
},
},
'html', --------------------------------- HTML
['jdtls'] = { --------------------------- Java
['root_dir'] = nvim_lsp.util.root_pattern('.git', 'pom.xml', 'build.xml'),
['init_options'] = {
['jvm_args'] = {['java.format.settings.url'] = vim.fn.stdpath('config')..'/eclipse-formatter.xml'},
['workspace'] = vim.fn.stdpath('cache')..'/java-workspaces'
}
},
['jsonls'] = { -------------------------- JSON
['settings'] = {
['json'] = {
['schemas' ] = vim.list_extend(
{
{
['description'] = 'JSON schema for Caddy v2',
['fileMatch'] = { '*caddy*.json' },
['name'] = 'caddy_schema.json',
['url'] = vim.fn.stdpath('data')..'/json-schemas/caddy_schema.json',
},
},
require('schemastore').json.schemas()
),
['validate'] = { ['enable'] = true }
} }
} }
}, })
'nixd', --------------------------------- Nix setup('gopls', {
'phpactor', ----------------------------- PHP settings = {
'pylsp', -------------------------------- Python gopls = { semanticTokens = true }
'solargraph', --------------------------- Ruby
'rust_analyzer', ------------------------ Rust
['sqlls'] = {
['cmd'] = {vim.fn.stdpath('data')..'/nvm/versions/node/v12.19.0/bin/sql-language-server', 'up', '--method', 'stdio'}
},
['terraformls'] = { --------------------- Terraform
['filetypes'] = { 'terraform', 'hcl', 'tf' }
},
-- The TS/JS server is chosen depending on an environment variable,
-- since denols is nicer for Deno based projects
------------------------ Deno TS/JS
------------------------------------ Typescript / JavaScript
(use_denols_for_typescript and 'denols' or 'tsserver'),
'vuels', -------------------------------- Vue
'svelte', ------------------------------- Svelte
['yamlls'] = { -------------------------- YAML
['settings'] = {
['yaml'] = {
['schemas'] = {
['https://json.schemastore.org/github-workflow'] = '.github/workflows/*.{yml,yaml}',
['https://json.schemastore.org/github-action'] = '.github/action.{yml,yaml}',
['https://json.schemastore.org/drone'] = '*.drone.{yml,yaml}',
['https://json.schemastore.org/swagger-2.0'] = 'swagger.{yml,yaml}',
} }
} })
} setup('phpactor')
} setup('pylsp')
}) do -- Setup all of the language servers. † setup('solargraph') -- ruby
if type(lsp_key) == 'number' then -- Enable the LSP with defaults. setup('rust_analyzer', {
-- The `lsp` is an index in this case. settings = {
nvim_lsp[lsp_settings].setup{ ['rust-analyzer'] = {
on_attach = on_attach, checkOnSave = { extraArgs = { "--target-dir", "/tmp/rust-analyzer-check" } },
flags = { diagnostics = { disabled = { 'inactive-code' } },
debounce_text_changes = 150,
},
capabilities = capabilities,
}
else -- Use the LSP's configuration.
lsp_settings.on_attach = on_attach
lsp_settings.capabilities = capabilities
nvim_lsp[lsp_key].setup(lsp_settings)
end
end --
-- configure floating diagnostics appearance, symbols
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- luasnip setup
local luasnip = require 'luasnip'
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, },
} }
})
setup('sqlls')
setup('salt_ls')
setup('ansiblels')
setup('dockerls')
setup('docker_compose_language_service')
setup('terraformls')
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#denols -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#denols
vim.g.markdown_fenced_languages = { vim.g.markdown_fenced_languages = {
"ts=typescript" "ts=typescript"
} }
-- Configure diagnostics -- Configure diagnostics
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = false, virtual_text = false,
signs = true, signs = true,
underline = true, underline = true,
update_in_insert = false, update_in_insert = false,
severity_sort = false, severity_sort = false,
}) })
-- Change diagnostic symbols in the sign column (gutter) -- Change diagnostic symbols in the sign column (gutter)
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } local signs = { Error = "x ", Warn = "! ", Hint = "? ", Info = "i " }
for type, icon in pairs(signs) do for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end end
EOF EOF
" have a fixed column for the diagnostics to appear in
" this removes the jitter when warnings/errors flow in
set signcolumn=yes:2

View file

@ -2,31 +2,22 @@
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
function AddTemplate(tmpl_file)
exe "0read " . a:tmpl_file
set nomodified
6
endfunction
autocmd BufNewFile shell.nix call AddTemplate("$XDG_DATA_HOME/nvim/templates/shell.nix.tmpl")
let g:gutentags_file_list_command = 'git ls-files' let g:gutentags_file_list_command = 'git ls-files'
" quick-scope
" https://github.com/unblevable/quick-scope " https://github.com/unblevable/quick-scope
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" Golang
" Go test, Def, Decls shortcut
nmap <Leader>got :GoTest<CR>:botright copen<CR>
autocmd FileType go nmap gd :GoDef<CR>
autocmd FileType go nmap gD :GoDecls<CR>
" Go formatting
autocmd FileType go setlocal noexpandtab shiftwidth=4 tabstop=4 softtabstop=4 nolist
" Caddyfile indentation " Caddyfile indentation
autocmd FileType caddyfile setlocal noexpandtab shiftwidth=8 tabstop=8 softtabstop=8 nolist autocmd FileType caddyfile setlocal noexpandtab shiftwidth=8 tabstop=8 softtabstop=8 nolist
" vim-go disable text-objects
let g:go_textobj_enabled = 0
" disable vim-go :GoDef short cut (gd)
" this is handled by LanguageClient [LC]
let g:go_def_mapping_enabled = 0
" GitGutter and vim Magit " GitGutter and vim Magit
" inspired by: https://jakobgm.com/posts/vim/git-integration/ " inspired by: https://jakobgm.com/posts/vim/git-integration/
" Don't map gitgutter keys automatically, set them ourselves " Don't map gitgutter keys automatically, set them ourselves
@ -51,9 +42,6 @@ nnoremap <leader>gP :! git push<CR> " git Push
nmap <Leader>[ :diffget //2<CR> nmap <Leader>[ :diffget //2<CR>
nmap <Leader>] :diffget //3<CR> nmap <Leader>] :diffget //3<CR>
" netrw
let g:netrw_fastbrowse=0
" Auto-FMT rust code on save " Auto-FMT rust code on save
let g:rustfmt_autosave = 1 let g:rustfmt_autosave = 1
@ -66,22 +54,52 @@ let g:highlightedyank_highlight_duration = 200
" Markdown options " Markdown options
let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_folding_disabled = 1
" Haskell options
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
" Emmet
let g:user_emmet_leader_key='<c-n>'
" Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" nnn " nnn
let g:nnn#command = 'nnn -d -e -H -r' let g:nnn#command = 'nnn -d -e -H -r'
nmap - :NnnPicker %<CR>
nmap <leader>n :NnnPicker %<CR>
nmap <leader>N :NnnPicker<CR>
lua <<EOF
local actions = require("telescope.actions")
local telescope = require("telescope")
telescope.setup{
defaults = {
mappings = {
n = {
["k"] = actions.move_selection_next,
["i"] = actions.move_selection_previous,
["I"] = actions.move_to_top,
["K"] = actions.move_to_bottom,
["<C-c>"] = actions.close,
},
},
},
pickers = {
find_files = {
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
},
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
}
}
telescope.load_extension('fzf')
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>f/', builtin.live_grep, {})
vim.keymap.set('n', '<leader>f?', builtin.builtin, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fr', builtin.command_history, {})
vim.keymap.set('n', '<leader>fc', builtin.commands, {})
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
EOF

View file

@ -1,36 +0,0 @@
self:
with self; ''
IFS=':' read -r -a INPUT <<< "$1"
FILE=''${INPUT[0]}
CENTER=''${INPUT[1]}
if [[ "$1" =~ ^[A-Za-z]:\\ ]]; then
FILE=$FILE:''${INPUT[1]}
CENTER=''${INPUT[2]}
fi
if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then
exit 1
fi
CENTER=''${CENTER/[^0-9]*/}
FILE="''${FILE/#\~\//$HOME/}"
if [ ! -r "$FILE" ]; then
echo "File not found ''${FILE}"
exit 1
fi
if [ -z "$CENTER" ]; then
CENTER=0
fi
exec cat "$FILE" \
| sed -e '/[#|\/\/ ?]-- copyright/,/[#\/\/]++/c\\' \
| ${pkgs.coreutils}/bin/tr -s '\n' \
| ${pkgs.bat}/bin/bat \
--style="''${BAT_STYLE:-numbers}" \
--color=always \
--pager=never \
--file-name="''$FILE" \
--highlight-line=$CENTER
''

View file

@ -1,20 +0,0 @@
"Usage:
" 1. Perform a vimgrep search
" :vimgrep /def/ *.rb
" 2. Issue QuickFixOpenAll command
" :QuickFixOpenAll
function! QuickFixOpenAll()
if empty(getqflist())
return
endif
let s:prev_val = ""
for d in getqflist()
let s:curr_val = bufname(d.bufnr)
if (s:curr_val != s:prev_val)
exec "edit " . s:curr_val
endif
let s:prev_val = s:curr_val
endfor
endfunction
command! QuickFixOpenAll call QuickFixOpenAll()

View file

@ -13,20 +13,3 @@ let g:airline#extensions#tabline#fnamemod = ':t' " Show just the filename
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
let g:airline_powerline_fonts = 1 " Use powerline fonts let g:airline_powerline_fonts = 1 " Use powerline fonts
let g:airline_theme = 'apprentice' let g:airline_theme = 'apprentice'
" Customize fzf colors to match your color scheme
" - fzf#wrap translates this to a set of `--color` options
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }

View file

@ -1,5 +1,6 @@
[formatter.nix] [formatter.nix]
command = "alejandra" command = "nix"
options = ["fmt"]
includes = ["*.nix"] includes = ["*.nix"]
excludes = ["pkgs/_sources/generated.nix"] excludes = ["pkgs/_sources/generated.nix"]