Quellcode durchsuchen

nixpkgs/neovim: load ts_ls preferences from helix config

Thomas Dy vor 3 Wochen
Ursprung
Commit
4787f055ab

+ 24 - 5
.config/nixpkgs/neovim/lsp.lua

@@ -9,6 +9,18 @@ vim.lsp.config("*", {
   }
 })
 
+local function read_helix_config()
+  local tinytoml = require("tinytoml")
+  local data = vim.secure.read(".helix/languages.toml")
+  if data ~= nil then
+    local status, data = pcall(tinytoml.parse, data, { load_from_string = true })
+    if status then
+      return data
+    end
+  end
+  return {}
+end
+
 vim.lsp.enable("bashls");
 vim.lsp.enable("eslint");
 
@@ -22,6 +34,17 @@ end
 if vim.fn.executable("deno") == 1 then
   vim.lsp.enable("deno");
 else
+  local preferences = {
+    importModuleSpecifierPreference = 'non-relative',
+    -- this prevents renames from aliasing when destructuring
+    providePrefixAndSuffixTextForRename = false,
+  }
+
+  local helix_preferences = vim.tbl_get(read_helix_config(), 'language-server', 'typescript-language-server', 'config', 'preferences')
+  if helix_preferences ~= nil then
+    preferences = vim.tbl_deep_extend('force', preferences, helix_preferences)
+  end
+
   local function make_settings()
     -- we disable formatting but these are still used when performing some code
     -- actions
@@ -38,11 +61,7 @@ else
   vim.lsp.config("ts_ls", {
     init_options = {
       completionDisableFilterText = true,
-      preferences = {
-        importModuleSpecifierPreference = 'non-relative',
-        -- this prevents renames from aliasing when destructuring
-        providePrefixAndSuffixTextForRename = false,
-      },
+      preferences = preferences,
     },
     settings = make_settings(),
     handlers = {

+ 7 - 0
.config/nixpkgs/neovim/plugins/default.nix

@@ -21,6 +21,13 @@ let
     "mistweaverco/kulala.nvim" = {
       patches = [ ./kulala-treesitter.patch ];
     };
+
+    "FourierTransformer/tinytoml" = {
+      postPatch = ''
+        mkdir lua
+        mv tinytoml.lua lua
+      '';
+    };
   };
 
   buildPlugin = name: spec:

+ 4 - 0
.config/nixpkgs/neovim/plugins/sources.json

@@ -79,5 +79,9 @@
   "tpope/vim-rsi": {
     "rev": "45540637ead22f011e8215f1c90142e49d946a54",
     "sha256": "0vr5mlna5f60dmhk4ims7g0ikqw15h21hr619xii1069ggddqr9v"
+  },
+  "FourierTransformer/tinytoml": {
+    "rev": "8fc9acf778eea141a36b7b42f55fcb6689fcfd3f",
+    "sha256": "1np8gymhlvklf45f9961ksxkm0nz3ppwkxcjaw8qxzr2fgd3kq9j"
   }
 }