config

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

lsp-vimscript.el (3257B)


      1 ;;; lsp-vimscript.el --- description -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020 emacs-lsp maintainers
      4 
      5 ;; Author: emacs-lsp maintainers
      6 ;; Keywords: lsp, vim, vimscript
      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 ;; LSP Clients for the VimScript Programming Language.
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-vim nil
     30   "LSP support for viml using vim-language-server."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/iamcco/vim-language-server"))
     33 
     34 (defcustom lsp-clients-vim-executable '("vim-language-server" "--stdio")
     35   "Command to start the vim language server."
     36   :group 'lsp-vim
     37   :risky t
     38   :type 'file)
     39 
     40 (defcustom lsp-clients-vim-initialization-options '((iskeyword . "vim iskeyword option")
     41                                                     (vimruntime . "/usr/bin/vim")
     42                                                     (runtimepath . "/usr/bin/vim")
     43                                                     (diagnostic . ((enable . t)))
     44                                                     (indexes . ((runtimepath . t)
     45                                                                 (gap . 100)
     46                                                                 (count . 3)))
     47                                                     (suggest . ((fromVimruntime . t)
     48                                                                 (fromRuntimepath . :json-false))))
     49   "Initialization options for vim language server."
     50   :group 'lsp-vim
     51   :type 'alist)
     52 
     53 (lsp-dependency 'vim-language-server
     54                 '(:system "vim-language-server")
     55                 '(:npm :package "vim-language-server"
     56                        :path "vim-language-server"))
     57 
     58 (lsp-register-client
     59  (make-lsp-client :new-connection (lsp-stdio-connection
     60                                    (lambda ()
     61                                      `(,(or (executable-find (cl-first lsp-clients-vim-executable))
     62                                             (lsp-package-path 'vim-language-server))
     63                                        ,@(cl-rest lsp-clients-vim-executable))))
     64                   :major-modes '(vimrc-mode vimscript-ts-mode)
     65                   :priority -1
     66                   :server-id 'vimls
     67                   :initialization-options (lambda () lsp-clients-vim-initialization-options)
     68                   :download-server-fn (lambda (_client callback error-callback _update?)
     69                                         (lsp-package-ensure 'vim-language-server
     70                                                             callback error-callback))))
     71 
     72 (lsp-consistency-check lsp-vimscript)
     73 
     74 (provide 'lsp-vimscript)
     75 ;;; lsp-vimscript.el ends here