feat(neovim): update config

This commit is contained in:
Felix Schröter 2021-05-05 00:05:37 +02:00
parent 4dce40bbaa
commit a01676e247
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58
7 changed files with 166 additions and 174 deletions

View file

@ -22,11 +22,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1619558193, "lastModified": 1620138697,
"narHash": "sha256-DljP5/9EX0eXEPhzCUFqFEHkkcFuXJBx1PTgcv0OgyM=", "narHash": "sha256-8Mgj+Fj4zGEI7oA9wbyqvdwq+46kAyd3barMIedWkho=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "18ad12d52b8cebbb57013865eec2be5125de050a", "rev": "64c5228c0828fff0c94c1d42f7225115c299ae08",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -38,11 +38,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1619464443, "lastModified": 1620074890,
"narHash": "sha256-R7WAb8EnkIJxxaF6GTHUPytjonhB4Zm0iatyWoW169A=", "narHash": "sha256-4Z8Zwpg0gPvqKbSsck1g9ql4E5NClGZdjyxbYoaXA4s=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17", "rev": "7cb76200088f45cd24a9aa67fd2f9657943d78a4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -69,11 +69,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1619617127, "lastModified": 1620161416,
"narHash": "sha256-A5+xGeftQfhcjMVGqWFYfjZZX1EaBBqkirVQe1ZyaXk=", "narHash": "sha256-GoKpxMWJrBMkVTvoKfRFedu7K+wUrbZUuMqTearjiu8=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "96572c099b8c13b520e764a2a8f516bc81ffcb2c", "rev": "ead34572175dc6de3b96b7ad6996315f84bede90",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -145,11 +145,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1619616710, "lastModified": 1619976063,
"narHash": "sha256-NIXeFf3zKsULIOx61P/vVsS30BD2YoshduSw680nJkM=", "narHash": "sha256-2tjVP95+qR1UzL8/UeV/xRJu7S2fRB7rf7enZedbrik=",
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "c33f92d9d69a73c77061e4fd47234662625cbdf9", "rev": "09fb9e425111878b58223852e87ed85e8a189e0d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -2,12 +2,12 @@
let let
neovim-unwrapped = pkgs.neovim-unwrapped.overrideAttrs (oldAttrs: rec { neovim-unwrapped = pkgs.neovim-unwrapped.overrideAttrs (oldAttrs: rec {
version = "2021-04-13"; version = "2021-05-04";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "neovim"; owner = "neovim";
repo = "neovim"; repo = "neovim";
rev = "c9817603cff5a5ca7ef4e4c12c8bf0e16d859e9a"; rev = "63d8a8f4e8b02e524d85aed08aa16c5d9815598c";
sha256 = "10ynpvrdm7sdkvmv96rgk0a6xa7489v65pxshml99vd4h7x8cfzl"; sha256 = "0zfrbvj8f2993n1gy37cnfmgixi6zgickzf44c1ll888k5f5rrx3";
}; };
nativeBuildInputs = oldAttrs.nativeBuildInputs nativeBuildInputs = oldAttrs.nativeBuildInputs
++ [ pkgs.utf8proc pkgs.tree-sitter ]; ++ [ pkgs.utf8proc pkgs.tree-sitter ];
@ -17,23 +17,23 @@ let
nvim-ts-autotag = buildVimPluginFrom2Nix { nvim-ts-autotag = buildVimPluginFrom2Nix {
pname = "nvim-ts-autotag"; pname = "nvim-ts-autotag";
version = "2021-03-26"; version = "2021-04-25";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "windwp"; owner = "windwp";
repo = "nvim-ts-autotag"; repo = "nvim-ts-autotag";
rev = "00b79b593af52585809e341c8dd1b7d839b3c466"; rev = "3d96e14e4400ce56e4fe0bf9b5e2e64b69dd7e65";
sha256 = "0a17jp6xn9vb8f205ivsw1fx1bapg6l5ywl1miacc06py459c7ch"; sha256 = "1ay93fak6m7x06ik8f4km00ln92l7cmlfmknms9czl2sl4pnrvzq";
}; };
}; };
nvim-ts-context-commentstring = buildVimPluginFrom2Nix { nvim-ts-context-commentstring = buildVimPluginFrom2Nix {
pname = "nvim-ts-context-commentstring"; pname = "nvim-ts-context-commentstring";
version = "2021-04-06"; version = "2021-04-17";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "JoosepAlviste"; owner = "JoosepAlviste";
repo = "nvim-ts-context-commentstring"; repo = "nvim-ts-context-commentstring";
rev = "5024c83e92c3988f6e7119bfa1b2347ae3a42c3e"; rev = "03a9c64d0b4249d91fd371de48bf3f6ac8a22d33";
sha256 = "13k7gwbrkbxjb3bf98zv6b64qqlas8z8xr9hxlr5l5hwmz5gw83i"; sha256 = "1d4yygrz05vnp24bszwncajcksnkg66x0qks7y5398rr675kzl2g";
}; };
}; };
@ -43,11 +43,7 @@ let
EOF EOF
''; '';
in { in {
home.packages = with pkgs; [ home.packages = with pkgs; [ graphviz ];
gcc # required for nvim-treesitter
tree-sitter
graphviz
];
programs.neovim = { programs.neovim = {
enable = true; enable = true;
@ -66,9 +62,8 @@ in {
vim-surround vim-surround
vim-commentary vim-commentary
vim-easymotion vim-easymotion
vim-which-key which-key-nvim
vim-fugitive vim-fugitive
registers-nvim
plenary-nvim plenary-nvim
gitsigns-nvim gitsigns-nvim
vim-test vim-test
@ -77,10 +72,7 @@ in {
wmgraphviz-vim wmgraphviz-vim
nvim-compe nvim-compe
# use :TSInstall & :TSUpdate to manage parsers (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars))
nvim-treesitter
# TODO https://github.com/NixOS/nixpkgs/pull/115445
# nvim-treesitter.withPlugins (builtins.attrValues pkgs.tree-sitter.builtGrammars)
nvim-treesitter-context nvim-treesitter-context
nvim-treesitter-refactor nvim-treesitter-refactor
nvim-treesitter-textobjects nvim-treesitter-textobjects
@ -94,12 +86,12 @@ in {
]; ];
extraConfig = with builtins; extraConfig = with builtins;
readFile ./init.vim # + readFile ./vim-surround-fix.vim readFile ./init.vim # + readFile ./vim-surround-fix.vim
+ readFile ./which-key.vim + readFile ./test.vim + vimLua (readFile ./which-key.lua) + vimLua (readFile ./gitsigns.lua)
+ vimLua (readFile ./gitsigns.lua) + readFile ./test.vim + vimLua (readFile ./lsp/extensions.lua)
+ vimLua (readFile ./lsp/extensions.lua) + readFile ./lsp/lsp.vim + readFile ./lsp/lsp.vim + vimLua (readFile ./lsp/lsp.lua)
+ vimLua (readFile ./lsp/lsp.lua) + vimLua (readFile ./treesitter.lua); + vimLua (readFile ./treesitter.lua);
withNodeJs = false; withNodeJs = false;
withPython = false; withPython3 = false;
}; };
xdg.configFile."nvim/filetype.vim".source = ./filetype.vim; xdg.configFile."nvim/filetype.vim".source = ./filetype.vim;

View file

@ -95,7 +95,6 @@ set splitbelow
map ; :Files<CR> map ; :Files<CR>
nmap <C-p> :NERDTreeToggle<CR> nmap <C-p> :NERDTreeToggle<CR>
" nmap <silent> <C-p> :Lexplore<CR> " nmap <silent> <C-p> :Lexplore<CR>
map <Leader> <Plug>(easymotion-prefix)
let g:netrw_banner = 0 let g:netrw_banner = 0
let g:netrw_liststyle = 3 let g:netrw_liststyle = 3

View file

@ -1,9 +1,9 @@
local config = require'lspconfig' local config = require'lspconfig'
-- format on save -- format on save
-- TODO often takes way longer to save than 1000 ms (e.g. 7000 ms in fitnesspilot-web)
local diagnosticls_on_attach = function(_, bufnr) local diagnosticls_on_attach = function(_, bufnr)
vim.api.nvim_command("au BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)") vim.api.nvim_command(
"au BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync(nil, nil, { 'tsserver', 'diagnosticls' })")
end end
local pid = vim.fn.getpid() local pid = vim.fn.getpid()
@ -18,7 +18,7 @@ config.dockerls.setup{}
config.rnix.setup{} config.rnix.setup{}
config.tsserver.setup{} config.tsserver.setup{}
config.omnisharp.setup{ config.omnisharp.setup{
cmd = {"omnisharp", "--languageserver", "--hostPID", tostring(pid)}; cmd = {"omnisharp", "--languageserver", "--hostPID", tostring(pid)},
} }
config.pyls.setup{} config.pyls.setup{}
config.terraformls.setup{} config.terraformls.setup{}
@ -27,126 +27,135 @@ config.hls.setup{}
-- based on: https://github.com/mikew/vimrc/blob/master/src/nvim/coc-settings.json -- based on: https://github.com/mikew/vimrc/blob/master/src/nvim/coc-settings.json
-- TODO breaks auto-completion when using with other lsp -- TODO breaks auto-completion when using with other lsp
-- TODO some ts projects are using tsc eslint plugin -- TODO some ts projects are using tsc eslint plugin
-- config.diagnosticls.setup{ config.diagnosticls.setup{
-- on_attach = diagnosticls_on_attach; on_attach = diagnosticls_on_attach,
-- filetypes = { filetypes = {
-- "javascript", "javascript",
-- "javascript.jsx", "javascript.jsx",
-- "javascriptreact", "javascriptreact",
-- "typescript", "typescript",
-- "typescript.jsx", "typescript.jsx",
-- "typescriptreact", "typescriptreact",
-- "json", "json",
-- "yaml", "yaml",
-- "markdown", "markdown",
-- "html", "html",
-- "css" "css"
-- }; },
-- init_options = { init_options = {
-- linters = { linters = {
-- eslint = { eslint = {
-- command = "eslint"; command = "eslint_d",
-- args = { args = {
-- "--stdin", "--cache",
-- "--stdin-filename", "--stdin",
-- "%filepath", "--stdin-filename",
-- "--format", "%filepath",
-- "json" "--format",
-- }; "json"
-- rootPatterns = {".git"}; },
-- debounce = 50; rootPatterns = {".eslintrc.js", ".eslintrc.json", ".git"},
-- sourceName = "eslint"; debounce = 50,
-- parseJson = { sourceName = "eslint",
-- errorsRoot = "[0].messages"; parseJson = {
-- line = "line"; errorsRoot = "[0].messages",
-- column = "column"; line = "line",
-- endLine = "endLine"; column = "column",
-- endColumn = "endColumn"; endLine = "endLine",
-- message = "${message} [${ruleId}]"; endColumn = "endColumn",
-- security = "severity"; message = "${message} [${ruleId}]",
-- }; security = "severity"
-- securities = { },
-- ["2"] = "error"; securities = {
-- ["1"] = "warning"; ["2"] = "error",
-- }; ["1"] = "warning"
-- }; },
-- stylelint = { },
-- command = "stylelint"; stylelint = {
-- args = { command = "stylelint",
-- "--stdin", args = {
-- "--formatter", "--stdin",
-- "json", "--formatter",
-- "--file", "json",
-- "%filepath" "--file",
-- }; "%filepath"
-- rootPatterns = {".git"}; },
-- debounce = 50; rootPatterns = {".git"},
-- sourceName = "stylelint"; debounce = 50,
-- parseJson = { sourceName = "stylelint",
-- errorsRoot = "[0].warnings"; parseJson = {
-- line = "line"; errorsRoot = "[0].warnings",
-- column = "column"; line = "line",
-- message = "${text}"; column = "column",
-- security = "severity"; message = "${text}",
-- }; security = "severity",
-- securities = { },
-- error = "error"; securities = {
-- warning = "warning"; error = "error",
-- }; warning = "warning",
-- }; },
-- }; },
-- filetypes = { },
-- javascript = {"eslint"}; filetypes = {
-- ["javascript.jsx"] = {"eslint"}; javascript = {"eslint"},
-- javascriptreact = {"eslint"}; ["javascript.jsx"] = {"eslint"},
-- typescript = {"eslint"}; javascriptreact = {"eslint"},
-- ["typescript.jsx"] = {"eslint"}; typescript = {"eslint"},
-- typescriptreact = {"eslint"}; ["typescript.jsx"] = {"eslint"},
-- css = {"stylelint"}; typescriptreact = {"eslint"},
-- }; css = {"stylelint"},
-- formatters = { },
-- eslint = { formatters = {
-- command = "eslint"; eslint = {
-- args = { command = "eslint_d",
-- "--fix", args = {
-- "%file" -- TODO eslint_d's stdin option doesn't work for some reason
-- }; -- "--cache",
-- rootPatterns = {".git"}; -- "--fix-to-stdout",
-- isStdout = 1; -- "--stdin",
-- doesWriteToFile = 1; -- "--stdin-filename",
-- }; -- "%filepath"
-- stylelint = { "--cache",
-- command = "stylelint"; "--fix",
-- args = { "%filepath"
-- "--stdin", },
-- "--fix", debounce = 50,
-- "--file", rootPatterns = {".eslintrc.js", ".eslintrc.json", ".git"},
-- "%filepath" isStdout = false,
-- }; doesWriteToFile = true,
-- rootPatterns = {".git"}; },
-- }; stylelint = {
-- prettier = { command = "stylelint",
-- command = "prettier"; args = {
-- args = { "--stdin",
-- "--stdin", "--fix",
-- "--stdin-filepath", "--file",
-- "%filepath" "%filepath"
-- }; },
-- rootPatterns = {".git"}; rootPatterns = {".stylelintrc.json", ".git"},
-- }; },
-- }; prettier = {
-- formatFiletypes = { command = "prettier",
-- javascript = {"eslint"}; args = {
-- ["javascript.jsx"] = {"eslint"}; "--stdin",
-- javascriptreact = {"eslint"}; "--stdin-filepath",
-- typescript = {"eslint"}; "%filepath"
-- ["typescript.jsx"] = {"eslint"}; },
-- typescriptreact = {"eslint"}; rootPatterns = {".prettierrc.json", ".git"},
-- json = {"prettier"}; },
-- yaml = {"prettier"}; },
-- markdown = {"prettier"}; formatFiletypes = {
-- html = {"prettier"}; javascript = {"eslint"},
-- css = {"stylelint"}; ["javascript.jsx"] = {"eslint"},
-- }; javascriptreact = {"eslint"},
-- }; typescript = {"eslint"},
-- } ["typescript.jsx"] = {"eslint"},
typescriptreact = {"eslint"},
json = {"prettier"},
yaml = {"prettier"},
markdown = {"prettier"},
html = {"prettier"},
css = {"stylelint"},
},
},
}

View file

@ -32,7 +32,7 @@ nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR> nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <leader>sd <cmd>lua vim.lsp.buf.document_symbol()<CR> nnoremap <silent> <leader>sd <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> <leader>sw <cmd>lua vim.lsp.buf.workspace_symbol()<CR> nnoremap <silent> <leader>sw <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <silent> <leader>f <cmd>lua vim.lsp.buf.formatting()<CR> nnoremap <silent> <leader>f <cmd>lua vim.lsp.buf.formatting_seq_sync(nil, nil, { 'tsserver', 'diagnosticls' })<CR>
nnoremap <silent> <leader>a <cmd>lua vim.lsp.buf.code_action()<CR> nnoremap <silent> <leader>a <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <silent> <leader>r <cmd>lua vim.lsp.buf.rename()<CR> nnoremap <silent> <leader>r <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent> <leader>d <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR> nnoremap <silent> <leader>d <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>

View file

@ -0,0 +1 @@
require("which-key").setup { }

View file

@ -1,9 +0,0 @@
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <localleader> :<c-u>WhichKeyVisual ','<CR>
nnoremap <silent> <leader><leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader><leader> :<c-u>WhichKeyVisual '<Space>'<CR>
nnoremap <silent> <localleader><localleader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <localleader><localleader> :<c-u>WhichKeyVisual ','<CR>