aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/termux_language_server.lua
blob: 3294ae05fe02fa17d7ada4305394ed4d2afcf099 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---@brief
---
--- https://github.com/termux/termux-language-server
---
--- Language server for various bash scripts such as Arch PKGBUILD, Gentoo ebuild, Termux build.sh, etc.

local util = require('lspconfig').util

---@type vim.lsp.Config
return {
  cmd = { 'termux-language-server' },
  root_dir = function(bufnr, on_dir)
    local patterns = {
      -- Termux
      'build.sh',
      '*.subpackage.sh',
      -- Arch/MSYS2
      'PKGBUILD',
      'makepkg.conf',
      '*.install',
      -- Gentoo
      'make.conf',
      'color.map',
      '*.ebuild',
      '*.eclass',
    }
    local fname = vim.api.nvim_buf_get_name(bufnr)
    local match = util.root_pattern(patterns)(fname)
    if match then
      on_dir(vim.fs.root(match, '.git') or match)
    end
  end,
}