Fix nil issue with server_ready function

This commit is contained in:
Jeremy Wall 2023-09-11 16:39:59 -04:00
parent f9acfc44ab
commit 154391d14c
3 changed files with 153 additions and 37 deletions

View File

@ -5,6 +5,10 @@
durnitisp-flake.url = "github:zaphar/durnitisp";
runwhen-flake.url = "github:zaphar/runwhen/v0.0.8";
agenix-flake.url = "github:ryantm/agenix";
nil-flake = {
url = "github:oxalica/nil";
#inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay-flake = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
@ -18,6 +22,7 @@
rust-overlay-flake,
jj-flake,
agenix-flake,
nil-flake,
... # We don't use the self or nixpkgs args here so we just glob it.
}: {
systemModule = system: let
@ -27,6 +32,7 @@
sile = sile-flake.defaultPackage.${system};
jj = jj-flake.packages."${system}".jujutsu;
age = agenix-flake.packages."${system}".default;
nil-pkg = nil-flake.packages."${system}".default;
in { config, pkgs, ... }: let
nvim-treesitter-csharp = pkgs.callPackage ./nvim-treesitter-csharp.nix {
inherit (pkgs.tree-sitter) buildGrammar;
@ -151,8 +157,7 @@ EOF";
rlwrap
docker-client
google-cloud-sdk
rnix-lsp
nil
nil-pkg
alloy6
omnisharp-roslyn
(tlaplus.override {

View File

@ -94,11 +94,30 @@ cmp.setup({
},
})
-- logging
--vim.lsp.set_log_level('trace')
--vim.lsp.log.set_format_func(vim.inspect)
local caps = vim.tbl_deep_extend(
'force',
vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities(),
-- File watching is disabled by default for neovim.
-- See: https://github.com/neovim/neovim/pull/22405
{ workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } },
{ window = { progress = false } }
);
local lspconfig = require("lspconfig")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Nix language server support
--lspconfig.nil_ls.setup{}
lspconfig.nil_ls.setup{
--single_file_support = true,
--on_attach = function(client, bufnr)
-- -- disable the semanticTokens because it has issues.
-- -- client.server_capabilities.semanticTokensProvider = nil
--end,
capabilities = caps,
}
local vim_pid = vim.fn.getpid()
@ -129,27 +148,27 @@ lspconfig.omnisharp.setup {
handlers = {
["textDocument/definition"] = require('omnisharp_extended').handler,
},
capabilities = capabilities
capabilities = caps,
}
--ocaml
lspconfig.ocamllsp.setup{
capabilities = capabilities
capabilities = caps
}
-- Java language server support
lspconfig.java_language_server.setup{
capabilities = capabilities
capabilities = caps
}
-- Typescript language server support
lspconfig.tsserver.setup{
capabilities = capabilities
capabilities = caps
}
-- Rust language server support
lspconfig.rust_analyzer.setup{
capabilities = capabilities
capabilities = caps
}
-- lua language server setup.
@ -172,7 +191,7 @@ lspconfig.lua_ls.setup{
},
},
},
capabilities = capabilities
capabilities = caps
}
-- lsp configuration
@ -193,13 +212,11 @@ vim.api.nvim_create_autocmd('LspAttach', {
vim.api.nvim_create_autocmd({'BufEnter', 'InsertLeave', 'CursorHold'}, {
callback = function(_)
if vim.lsp.buf.server_ready() then
local clients = vim.lsp.get_active_clients()
for cid = 1, #clients do
if clients[cid].server_capabilities.codelens then
vim.lsp.codelens.refresh()
break
end
local clients = vim.lsp.get_active_clients()
for cid = 1, #clients do
if clients[cid].server_capabilities.codelens then
vim.lsp.codelens.refresh()
break
end
end
end,
@ -467,6 +484,3 @@ vim.keymap.set("n", "<Leader>rr", vim.lsp.codelens.run)
-- Show whatever errors we have in our trouble pane
vim.keymap.set("n", "<Leader>se", "<cmd>TroubleToggle<cr>", { silent = true, noremap = true })
-- logging
--vim.lsp.set_log_level("debug")
--vim.lsp.log.set_format_func(vim.inspect)

131
nix/darwin/flake.lock generated
View File

@ -25,6 +25,7 @@
"agenix-flake": "agenix-flake",
"durnitisp-flake": "durnitisp-flake",
"jj-flake": "jj-flake",
"nil-flake": "nil-flake",
"nixpkgs": [
"nixpkgs"
],
@ -34,12 +35,12 @@
},
"locked": {
"lastModified": 1,
"narHash": "sha256-vks0c+ByEs5/F4x6nMkDecgUAXOLNnVSxaSJEoywhRg=",
"path": "/nix/store/fb05dg2zd1hl4kpmwjfynp3a9hpkdmwz-source/nix/base-system",
"narHash": "sha256-QPIUjaQuh6yWhvc0R25v3OEy3tGhia3cuGMFemZjnCU=",
"path": "/nix/store/mzmyyi3swmlp8sncx2hi3hzrk6m4fik3-source/nix/base-system",
"type": "path"
},
"original": {
"path": "/nix/store/fb05dg2zd1hl4kpmwjfynp3a9hpkdmwz-source/nix/base-system",
"path": "/nix/store/mzmyyi3swmlp8sncx2hi3hzrk6m4fik3-source/nix/base-system",
"type": "path"
}
},
@ -68,7 +69,7 @@
},
"darwin_2": {
"inputs": {
"nixpkgs": "nixpkgs_6"
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1692248770,
@ -186,6 +187,24 @@
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1687709756,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
@ -200,9 +219,9 @@
"type": "github"
}
},
"flake-utils_4": {
"flake-utils_5": {
"inputs": {
"systems": "systems_2"
"systems": "systems_3"
},
"locked": {
"lastModified": 1681202837,
@ -218,9 +237,9 @@
"type": "github"
}
},
"flake-utils_5": {
"flake-utils_6": {
"inputs": {
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1681202837,
@ -336,7 +355,7 @@
},
"naersk_2": {
"inputs": {
"nixpkgs": "nixpkgs_4"
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1650101877,
@ -352,6 +371,26 @@
"type": "github"
}
},
"nil-flake": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_4",
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1694177726,
"narHash": "sha256-eaYATUkElEbXGcehShhYfcGhrjfTMQEmJqxvO+/5ciw=",
"owner": "oxalica",
"repo": "nil",
"rev": "4775e34c30f6101a9bb4364a0c7e4aae4ae43f11",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "nil",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1677676435,
@ -397,6 +436,22 @@
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1690441914,
"narHash": "sha256-Ac+kJQ5z9MDAMyzSc0i0zJDx2i3qi9NjlW5Lz285G/I=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "db8672b8d0a2593c2405aed0c1dfa64b2a2f428f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1650109093,
"narHash": "sha256-tqlnKrAdJktRLXTou9le0oTqrYBAFpGscV5RADdpArU=",
@ -410,7 +465,7 @@
"type": "indirect"
}
},
"nixpkgs_5": {
"nixpkgs_6": {
"locked": {
"lastModified": 1682109806,
"narHash": "sha256-d9g7RKNShMLboTWwukM+RObDWWpHKaqTYXB48clBWXI=",
@ -426,7 +481,7 @@
"type": "github"
}
},
"nixpkgs_6": {
"nixpkgs_7": {
"locked": {
"lastModified": 1687274257,
"narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=",
@ -439,7 +494,7 @@
"type": "indirect"
}
},
"nixpkgs_7": {
"nixpkgs_8": {
"locked": {
"lastModified": 1693932334,
"narHash": "sha256-7VhSLyAaenNlYzWT1dp70uJvrwHXu+Bmlvk5i1rpSC8=",
@ -459,13 +514,13 @@
"inputs": {
"base-system": "base-system",
"darwin": "darwin_2",
"nixpkgs": "nixpkgs_7"
"nixpkgs": "nixpkgs_8"
}
},
"runwhen-flake": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"flake-utils": "flake-utils_4",
"naersk": "naersk_2"
},
"locked": {
@ -512,7 +567,7 @@
},
"rust-overlay-flake": {
"inputs": {
"flake-utils": "flake-utils_4",
"flake-utils": "flake-utils_5",
"nixpkgs": [
"base-system",
"nixpkgs"
@ -532,13 +587,40 @@
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"base-system",
"nil-flake",
"flake-utils"
],
"nixpkgs": [
"base-system",
"nil-flake",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688783586,
"narHash": "sha256-HHaM2hk2azslv1kH8zmQxXo2e7i5cKgzNIuK4yftzB0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "7a29283cc242c2486fc67f60b431ef708046d176",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"sile-flake": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_5",
"flake-utils": "flake-utils_6",
"gitignore": "gitignore",
"libtexpdf-src": "libtexpdf-src",
"nixpkgs": "nixpkgs_5"
"nixpkgs": "nixpkgs_6"
},
"locked": {
"lastModified": 1692759315,
@ -598,6 +680,21 @@
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",