From 8ce9e36a829cada43d8f6e322d33911e587ba77d Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Sat, 18 Dec 2021 23:05:38 +0100 Subject: [PATCH] Switch to null-ls --- config/nvim/efm.yml | 78 ------------------------ config/nvim/lua/nifoc/config/lsp.lua | 36 +---------- config/nvim/lua/nifoc/config/null_ls.lua | 12 ++++ config/nvim/lua/nifoc/plugins.lua | 1 + programs/nvim/default.nix | 2 +- programs/nvim/plugins.nix | 42 ++++++++----- programs/nvim/plugins.txt | 1 + 7 files changed, 43 insertions(+), 129 deletions(-) delete mode 100644 config/nvim/efm.yml create mode 100644 config/nvim/lua/nifoc/config/null_ls.lua diff --git a/config/nvim/efm.yml b/config/nvim/efm.yml deleted file mode 100644 index 3447f28..0000000 --- a/config/nvim/efm.yml +++ /dev/null @@ -1,78 +0,0 @@ -version: 2 -root-markers: - - .git/ - - flake.nix -lint-debounce: '200ms' - -tools: - dockerfile-hadolint: &dockerfile-hadolint - lint-command: 'efm-hadolint' - lint-formats: - - '%f:%l:%trror: %m' - - '%f:%l:%tarning: %m' - - '%f:%l:%tnfo: %m' - - '%f:%l:%ttyle: %m' - - elixir-credo: &elixir-credo - lint-command: > - mix credo suggest --all-priorities --format flycheck --read-from-stdin ${INPUT} | - sed "s/ R:/ H:/; s/ D:/ I:/; s/ C:/ W:/" - lint-stdin: true - lint-formats: - - '%f:%l:%c: %t: %m' - - '%f:%l: %t: %m' - root-markers: - - mix.lock - - mix.exs - - eruby-erb: &eruby-erb - lint-command: 'erb -x -T - | ruby -c' - lint-stdin: true - lint-offset: 1 - - fish-indent: &fish-indent - format-command: 'fish_indent' - format-stdin: true - - javascript-eslint: &javascript-eslint - lint-command: 'eslint_d -f visualstudio --stdin --stdin-filename ${INPUT}' - lint-ignore-exit-code: true - lint-stdin: true - lint-formats: - - "%f(%l,%c): %tarning %m" - - "%f(%l,%c): %rror %m" - format-command: 'eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}' - format-stdin: true - root-markers: - - .eslintrc.js - - sh-shfmt: &sh-shfmt - format-command: 'shfmt -i 2' - format-stdin: true - - sh-shellcheck: &sh-shellcheck - lint-command: 'shellcheck -f gcc -x' - lint-formats: - - '%f:%l:%c: %trror: %m' - - '%f:%l:%c: %tarning: %m' - - '%f:%l:%c: %tote: %m' - -languages: - dockerfile: - - <<: *dockerfile-hadolint - - elixir: - - <<: *elixir-credo - - eruby: - - <<: *eruby-erb - - fish: - - <<: *fish-indent - - javascript: - - <<: *javascript-eslint - - sh: - - <<: *sh-shellcheck - - <<: *sh-shfmt diff --git a/config/nvim/lua/nifoc/config/lsp.lua b/config/nvim/lua/nifoc/config/lsp.lua index e1cb65e..1a28a17 100644 --- a/config/nvim/lua/nifoc/config/lsp.lua +++ b/config/nvim/lua/nifoc/config/lsp.lua @@ -79,10 +79,10 @@ local default_config = { } local default_servers = { - 'angularls', 'bashls', 'cssls', 'dockerls', + 'eslint', 'html', 'rnix', 'sqls', @@ -153,37 +153,3 @@ lsp.sumneko_lua.setup(vim.tbl_extend('force', default_config, { }, }, })) - --- Try to start efm as the last language server - -lsp.efm.setup(vim.tbl_extend('force', default_config, { - cmd = { - 'efm-langserver', - '-c', - vim.fn.globpath('~', '.config/nvim/efm.yml'), - }, - filetypes = { - 'dockerfile', - 'elixir', - 'fish', - 'javascript', - 'sh', - }, - on_attach = function(client, bufnr) - local disable_formatter_ft = { 'dockerfile', 'elixir' } - local slow_ft = {} - - if vim.tbl_contains(disable_formatter_ft, vim.bo.filetype) then - client.resolved_capabilities.document_formatting = false - end - - if vim.tbl_contains(slow_ft, vim.bo.filetype) then - client.resolved_capabilities.text_document_did_change = vim.lsp.protocol.TextDocumentSyncKind.None - end - - client.resolved_capabilities.document_symbol = false - client.resolved_capabilities.workspace_symbol = false - - custom_attach(client, bufnr) - end, -})) diff --git a/config/nvim/lua/nifoc/config/null_ls.lua b/config/nvim/lua/nifoc/config/null_ls.lua new file mode 100644 index 0000000..4445ee1 --- /dev/null +++ b/config/nvim/lua/nifoc/config/null_ls.lua @@ -0,0 +1,12 @@ +local null_ls = require('null-ls') +local builtins = null_ls.builtins + +null_ls.setup({ + sources = { + builtins.diagnostics.credo, + builtins.formatting.fish_indent, + builtins.diagnostics.hadolint, + builtins.diagnostics.shellcheck.with({extra_args = { '-f', 'gcc', '-x' }}), + builtins.formatting.shfmt.with({extra_args = { '-i', '2' }}), + }, +}) diff --git a/config/nvim/lua/nifoc/plugins.lua b/config/nvim/lua/nifoc/plugins.lua index f4224b7..ae411b6 100644 --- a/config/nvim/lua/nifoc/plugins.lua +++ b/config/nvim/lua/nifoc/plugins.lua @@ -39,6 +39,7 @@ require('nifoc.config.todo_comments') -- LSP require('nifoc.config.lsp') +require('nifoc.config.null_ls') require('nifoc.config.lsp_trouble') require('nifoc.config.illuminate') diff --git a/programs/nvim/default.nix b/programs/nvim/default.nix index e54b0a2..3aebb76 100644 --- a/programs/nvim/default.nix +++ b/programs/nvim/default.nix @@ -22,7 +22,6 @@ in tree-sitter # LSP - efm-langserver nodePackages.bash-language-server nodePackages.dockerfile-language-server-nodejs nodePackages.vscode-langservers-extracted @@ -70,6 +69,7 @@ in # LSP nvim-lspconfig + null-ls-nvim trouble-nvim lspkind-nvim lsp-status-nvim diff --git a/programs/nvim/plugins.nix b/programs/nvim/plugins.nix index c687be5..2fd2bb2 100644 --- a/programs/nvim/plugins.nix +++ b/programs/nvim/plugins.nix @@ -99,12 +99,12 @@ }; nvim-treesitter = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "nvim-treesitter"; - version = "1639733818"; + version = "1639864170"; src = pkgs.fetchFromGitHub { owner = "nvim-treesitter"; repo = "nvim-treesitter"; - rev = "296c28be5396da069e436f58bdaa541506f99fb5"; - sha256 = "+IPX8rrNIkZCIsY/6hzm4vLuSrTgA+4R54hmJFvIV/4="; + rev = "e01c7ce9727b9d18b71b41cc792cb4719e469598"; + sha256 = "I9+GPTRkKaT8MN9Vqeif6SG3NqzUA7qvKxcYWVsSHKY="; fetchSubmodules = false; }; meta.homepage = "https://github.com/nvim-treesitter/nvim-treesitter"; @@ -206,6 +206,18 @@ }; meta.homepage = "https://github.com/neovim/nvim-lspconfig"; }; + null-ls-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { + pname = "null-ls.nvim"; + version = "1639855372"; + src = pkgs.fetchFromGitHub { + owner = "jose-elias-alvarez"; + repo = "null-ls.nvim"; + rev = "b9a1db1990e6c7e27cfe5f6b0a7fbae47dc63849"; + sha256 = "tv1IAfrWe7lJGOY25WnxgKPhgxpGQ1OwaDs6pIbuagA="; + fetchSubmodules = false; + }; + meta.homepage = "https://github.com/jose-elias-alvarez/null-ls.nvim"; + }; nvim-web-devicons = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "nvim-web-devicons"; version = "1639689176"; @@ -256,12 +268,12 @@ }; nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "nvim-cmp"; - version = "1639533818"; + version = "1639842196"; src = pkgs.fetchFromGitHub { owner = "hrsh7th"; repo = "nvim-cmp"; - rev = "4efecf7f5b86949de387e63fa86715bc39f92219"; - sha256 = "RTUqz4hTvnaLNMaqQcDJMRxv2+c2nf+IoiEWGm69cfU="; + rev = "b11f8bbee3d7ba5190b043e23bd6f5b9cb82382c"; + sha256 = "xiC5cCUE18S5M2rxDXCTwLV5ZmCy6Z7lDzur53xVAQ0="; fetchSubmodules = false; }; meta.homepage = "https://github.com/hrsh7th/nvim-cmp"; @@ -280,12 +292,12 @@ }; LuaSnip = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "LuaSnip"; - version = "1639761885"; + version = "1639780167"; src = pkgs.fetchFromGitHub { owner = "L3MON4D3"; repo = "LuaSnip"; - rev = "6c2499594871d8403a5d7db80cbe35bc317fc8ed"; - sha256 = "DEEF9nRVVCA3ks+NE/wrnlm2ik8jXu9t5TfjichgfUM="; + rev = "6bcd3bb65ebb3e82afb460587590a80350eba1a1"; + sha256 = "Vov0jpRpUkubfFmh93pC13pa7a/97e8zy2nsT0rUjE4="; fetchSubmodules = false; }; meta.homepage = "https://github.com/L3MON4D3/LuaSnip"; @@ -316,12 +328,12 @@ }; cmp-path = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "cmp-path"; - version = "1639492848"; + version = "1639837442"; src = pkgs.fetchFromGitHub { owner = "hrsh7th"; repo = "cmp-path"; - rev = "56a0fe5c46835ecc6323bda69f3924758b991590"; - sha256 = "/dFsJ6er4H0jF79RvoWRh77asEKFyxoN2Yw5Gml72Pc="; + rev = "e1a69161703171f5804d311005a73b742fbda123"; + sha256 = "wdARGRz1TU/Igb2J49lB2zp/+gFEnTQFipMZOM2A81o="; fetchSubmodules = false; }; meta.homepage = "https://github.com/hrsh7th/cmp-path"; @@ -460,12 +472,12 @@ }; lualine-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "lualine.nvim"; - version = "1639398150"; + version = "1639832649"; src = pkgs.fetchFromGitHub { owner = "nvim-lualine"; repo = "lualine.nvim"; - rev = "c4a09735a68c30981c223310848f0649235ec2be"; - sha256 = "EKzI6+mslbJR8TjmASpuHZlZ6gUh3O/+Stelz3QKsT8="; + rev = "3a17c8f05aae1f148b8af595b46fea18b74d0573"; + sha256 = "VOIbDCeOBV1YPXl9VMz6aKaC7F+CSnlr/AEWX8jNw3s="; fetchSubmodules = false; }; meta.homepage = "https://github.com/nvim-lualine/lualine.nvim"; diff --git a/programs/nvim/plugins.txt b/programs/nvim/plugins.txt index 88a13bd..7322594 100644 --- a/programs/nvim/plugins.txt +++ b/programs/nvim/plugins.txt @@ -15,6 +15,7 @@ nvim-telescope/telescope.nvim nvim-telescope/telescope-fzf-native.nvim/make ahmedkhalf/project.nvim neovim/nvim-lspconfig +jose-elias-alvarez/null-ls.nvim kyazdani42/nvim-web-devicons folke/trouble.nvim onsails/lspkind-nvim