config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-nix.el (3934B)


      1 ;;; lsp-nix.el --- lsp-mode nix integration    -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020 lsp-mode maintainers
      4 
      5 ;; Author: Seong Yong-ju <sei40kr@gmail.com>
      6 ;; Keywords: languages
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 
     23 ;; Client for the rnix language server.
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-nix-rnix nil
     30   "LSP support for Nix, using rnix-lsp."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/nix-community/rnix-lsp"))
     33 
     34 (defcustom lsp-nix-rnix-server-path "rnix-lsp"
     35   "Executable path for the server."
     36   :group 'lsp-nix-rnix
     37   :type 'string
     38   :package-version '(lsp-mode . "8.0.0"))
     39 
     40 (lsp-register-client
     41  (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-rnix-server-path))
     42                   :major-modes '(nix-mode nix-ts-mode)
     43                   :server-id 'rnix-lsp
     44                   :priority -2))
     45 
     46 (defgroup lsp-nix-nixd nil
     47   "LSP support for Nix, using nixd language server."
     48   :group 'lsp-mode
     49   :link '(url-link "https://github.com/nix-community/nixd"))
     50 
     51 (defcustom lsp-nix-nixd-server-path "nixd"
     52   "Executable path for the server."
     53   :group 'lsp-nix-nixd
     54   :type 'string
     55   :package-version '(lsp-mode . "8.0.0"))
     56 
     57 (lsp-register-client
     58  (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-nixd-server-path))
     59                   :major-modes '(nix-mode)
     60                   :server-id 'nixd-lsp
     61                   :priority -1))
     62 
     63 (defgroup lsp-nix-nil nil
     64   "LSP support for Nix, using nil."
     65   :group 'lsp-mode
     66   :link '(url-link "https://github.com/oxalica/nil"))
     67 
     68 (defcustom lsp-nix-nil-server-path "nil"
     69   "Executable path for the server."
     70   :group 'lsp-nix-nil
     71   :type 'string
     72   :package-version '(lsp-mode . "9.0.0"))
     73 
     74 (lsp-defcustom lsp-nix-nil-formatter nil
     75   "External formatter command with arguments.
     76 
     77   Example [nixpkgs-fmt]."
     78   :type 'lsp-string-vector
     79   :group 'lsp-nix-nil
     80   :lsp-path "nil.formatting.command"
     81   :package-version '(lsp-mode . "9.0.0"))
     82 
     83 (lsp-defcustom lsp-nix-nil-ignored-diagnostics nil
     84   "Ignored diagnostic kinds."
     85   :type 'lsp-string-vector
     86   :group 'lsp-nix-nil
     87   :lsp-path "nil.diagnostics.ignored"
     88   :package-version '(lsp-mode . "9.0.0"))
     89 
     90 (lsp-defcustom lsp-nix-nil-exclude-files-diagnostic nil
     91   "Files to exclude from showing diagnostics."
     92   :type 'lsp-string-vector
     93   :group 'lsp-nix-nil
     94   :lsp-path "nil.diagnostics.excludedFiles"
     95   :package-version '(lsp-mode . "9.0.0"))
     96 (lsp-defcustom lsp-nix-nil-max-mem 10000
     97   "Max Memory MB"
     98   :type 'number
     99   :group 'lsp-nix-nil
    100   :lsp-path "nil.nix.maxMemoryMB"
    101   :package-version '(lsp-mode . "9.0.0"))
    102 (lsp-defcustom lsp-nix-nil-auto-eval-inputs t
    103   "Auto Eval Inputs"
    104   :type 'boolean
    105   :group 'lsp-nix-nil
    106   :lsp-path "nil.nix.flake.autoEvalInputs"
    107   :package-version '(lsp-mode . "9.0.0"))
    108 
    109 (lsp-register-client
    110  (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-nil-server-path))
    111                   :major-modes '(nix-mode nix-ts-mode)
    112                   :initialized-fn (lambda (workspace)
    113                     (with-lsp-workspace workspace
    114                       (lsp--set-configuration
    115                        (lsp-configuration-section "nil"))))
    116                   :synchronize-sections '("nil")
    117                   :server-id 'nix-nil))
    118 
    119 (lsp-consistency-check lsp-nix)
    120 
    121 (provide 'lsp-nix)
    122 ;;; lsp-nix.el ends here