default-config.lua 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. CONFIG_PATH = os.getenv "HOME" .. "/.local/share/lunarvim/lvim"
  2. DATA_PATH = vim.fn.stdpath "data"
  3. CACHE_PATH = vim.fn.stdpath "cache"
  4. TERMINAL = vim.fn.expand "$TERMINAL"
  5. USER = vim.fn.expand "$USER"
  6. lvim = {
  7. leader = "space",
  8. colorscheme = "spacegray",
  9. line_wrap_cursor_movement = true,
  10. transparent_window = false,
  11. format_on_save = true,
  12. vsnip_dir = os.getenv "HOME" .. "/.config/snippets",
  13. database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 },
  14. keys = {},
  15. -- TODO why do we need this?
  16. builtin = {
  17. lspinstall = {},
  18. telescope = {},
  19. compe = {},
  20. autopairs = {},
  21. treesitter = {},
  22. nvimtree = {},
  23. gitsigns = {},
  24. which_key = {},
  25. comment = {},
  26. rooter = {},
  27. galaxyline = {},
  28. bufferline = {},
  29. dap = {},
  30. dashboard = {},
  31. terminal = {},
  32. },
  33. lsp = {
  34. diagnostics = {
  35. virtual_text = {
  36. prefix = "",
  37. spacing = 0,
  38. },
  39. signs = true,
  40. underline = true,
  41. },
  42. override = {},
  43. document_highlight = true,
  44. popup_border = "single",
  45. default_keybinds = true,
  46. on_attach_callback = nil,
  47. },
  48. plugins = {
  49. -- use lv-config.lua for this not put here
  50. },
  51. autocommands = {},
  52. }
  53. local schemas = nil
  54. local common_on_attach = require("lsp").common_on_attach
  55. local common_capabilities = require("lsp").common_capabilities()
  56. local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls")
  57. if status_ok then
  58. schemas = jsonls_settings.get_default_schemas()
  59. end
  60. -- TODO move all of this into lang specific files, only require when using
  61. lvim.lang = {
  62. c = {
  63. formatter = {
  64. exe = "clang_format",
  65. args = {},
  66. stdin = true,
  67. },
  68. linters = {
  69. "clangtidy",
  70. },
  71. lsp = {
  72. provider = "clangd",
  73. setup = {
  74. cmd = {
  75. DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd",
  76. "--background-index",
  77. "--header-insertion=never",
  78. "--cross-file-rename",
  79. "--clang-tidy",
  80. "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
  81. },
  82. on_attach = common_on_attach,
  83. capabilities = common_capabilities,
  84. },
  85. },
  86. },
  87. cpp = {
  88. formatter = {
  89. exe = "clang_format",
  90. args = {},
  91. stdin = true,
  92. },
  93. linters = {
  94. "cppcheck",
  95. "clangtidy",
  96. },
  97. lsp = {
  98. provider = "clangd",
  99. setup = {
  100. cmd = {
  101. DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd",
  102. "--background-index",
  103. "--header-insertion=never",
  104. "--cross-file-rename",
  105. "--clang-tidy",
  106. "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
  107. },
  108. on_attach = common_on_attach,
  109. capabilities = common_capabilities,
  110. },
  111. },
  112. },
  113. cs = {
  114. formatter = {
  115. exe = "",
  116. args = {},
  117. },
  118. linters = {},
  119. lsp = {
  120. provider = "omnisharp",
  121. setup = {
  122. cmd = {
  123. DATA_PATH .. "/lspinstall/csharp/omnisharp/run",
  124. "--stdio",
  125. },
  126. on_attach = common_on_attach,
  127. capabilities = common_capabilities,
  128. },
  129. },
  130. },
  131. cmake = {
  132. formatter = {
  133. exe = "clang-format",
  134. args = {},
  135. },
  136. lsp = {
  137. provider = "cmake",
  138. setup = {
  139. cmd = {
  140. DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server",
  141. "--stdio",
  142. },
  143. on_attach = common_on_attach,
  144. capabilities = common_capabilities,
  145. },
  146. },
  147. },
  148. clojure = {
  149. lsp = {
  150. provider = "clojure_lsp",
  151. setup = {
  152. cmd = {
  153. DATA_PATH .. "/lspinstall/clojure/clojure-lsp",
  154. "--stdio",
  155. },
  156. on_attach = common_on_attach,
  157. capabilities = common_capabilities,
  158. },
  159. },
  160. },
  161. css = {
  162. formatter = {
  163. exe = "prettier",
  164. args = {},
  165. },
  166. lsp = {
  167. provider = "cssls",
  168. setup = {
  169. cmd = {
  170. "node",
  171. DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js",
  172. "--stdio",
  173. },
  174. on_attach = common_on_attach,
  175. capabilities = common_capabilities,
  176. },
  177. },
  178. },
  179. dart = {
  180. lsp = {
  181. provider = "dartls",
  182. setup = {
  183. cmd = {
  184. "dart",
  185. "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
  186. "--lsp",
  187. },
  188. on_attach = common_on_attach,
  189. capabilities = common_capabilities,
  190. },
  191. },
  192. formatter = {
  193. exe = "dart",
  194. args = { "format" },
  195. stdin = true,
  196. },
  197. },
  198. docker = {
  199. lsp = {
  200. provider = "dockerls",
  201. setup = {
  202. cmd = {
  203. DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver",
  204. "--stdio",
  205. },
  206. on_attach = common_on_attach,
  207. capabilities = common_capabilities,
  208. },
  209. },
  210. },
  211. elixir = {
  212. formatter = {
  213. exe = "mix",
  214. args = { "format" },
  215. stdin = true,
  216. },
  217. lsp = {
  218. provider = "elixirls",
  219. setup = {
  220. cmd = {
  221. DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh",
  222. },
  223. on_attach = common_on_attach,
  224. capabilities = common_capabilities,
  225. },
  226. },
  227. },
  228. elm = {
  229. lsp = {
  230. provider = "elmls",
  231. setup = {
  232. cmd = {
  233. DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server",
  234. },
  235. on_attach = common_on_attach,
  236. init_options = {
  237. elmAnalyseTrigger = "change",
  238. elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format",
  239. elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/",
  240. elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test",
  241. },
  242. },
  243. },
  244. },
  245. erlang = {
  246. lsp = {
  247. provider = "erlangls",
  248. setup = {
  249. cmd = {
  250. "erlang_ls",
  251. },
  252. on_attach = common_on_attach,
  253. capabilities = common_capabilities,
  254. },
  255. },
  256. },
  257. emmet = { active = false },
  258. go = {
  259. formatter = {
  260. exe = "gofmt",
  261. args = {},
  262. stdin = true,
  263. },
  264. linters = {
  265. "golangcilint",
  266. "revive",
  267. },
  268. lsp = {
  269. provider = "gopls",
  270. setup = {
  271. cmd = {
  272. DATA_PATH .. "/lspinstall/go/gopls",
  273. },
  274. on_attach = common_on_attach,
  275. capabilities = common_capabilities,
  276. },
  277. },
  278. },
  279. graphql = {
  280. lsp = {
  281. provider = "graphql",
  282. setup = {
  283. cmd = {
  284. "graphql-lsp",
  285. "server",
  286. "-m",
  287. "stream",
  288. },
  289. on_attach = common_on_attach,
  290. capabilities = common_capabilities,
  291. },
  292. },
  293. },
  294. html = {
  295. linters = {
  296. "tidy",
  297. -- https://docs.errata.ai/vale/scoping#html
  298. "vale",
  299. },
  300. lsp = {
  301. provider = "html",
  302. setup = {
  303. cmd = {
  304. "node",
  305. DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js",
  306. "--stdio",
  307. },
  308. on_attach = common_on_attach,
  309. capabilities = common_capabilities,
  310. },
  311. },
  312. },
  313. java = {
  314. formatter = {
  315. exe = "prettier",
  316. args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) },
  317. },
  318. lsp = {
  319. provider = "jdtls",
  320. setup = {
  321. cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" },
  322. on_attach = common_on_attach,
  323. capabilities = common_capabilities,
  324. },
  325. },
  326. },
  327. json = {
  328. formatter = {
  329. exe = "python",
  330. args = { "-m", "json.tool" },
  331. stdin = true,
  332. },
  333. lsp = {
  334. provider = "jsonls",
  335. setup = {
  336. cmd = {
  337. "node",
  338. DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  339. "--stdio",
  340. },
  341. on_attach = common_on_attach,
  342. capabilities = common_capabilities,
  343. settings = {
  344. json = {
  345. schemas = schemas,
  346. -- = {
  347. -- {
  348. -- fileMatch = { "package.json" },
  349. -- url = "https://json.schemastore.org/package.json",
  350. -- },
  351. -- },
  352. },
  353. },
  354. commands = {
  355. Format = {
  356. function()
  357. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  358. end,
  359. },
  360. },
  361. },
  362. },
  363. },
  364. julia = {
  365. lsp = {
  366. provider = "julials",
  367. setup = {
  368. {
  369. "julia",
  370. "--startup-file=no",
  371. "--history-file=no",
  372. -- vim.fn.expand "~/.config/nvim/lua/lsp/julia/run.jl",
  373. CONFIG_PATH .. "/utils/julia/run.jl",
  374. },
  375. on_attach = common_on_attach,
  376. capabilities = common_capabilities,
  377. },
  378. },
  379. },
  380. kotlin = {
  381. lsp = {
  382. provider = "kotlin_language_server",
  383. setup = {
  384. cmd = {
  385. DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server",
  386. },
  387. on_attach = common_on_attach,
  388. root_dir = function(fname)
  389. local util = require "lspconfig/util"
  390. local root_files = {
  391. "settings.gradle", -- Gradle (multi-project)
  392. "settings.gradle.kts", -- Gradle (multi-project)
  393. "build.xml", -- Ant
  394. "pom.xml", -- Maven
  395. }
  396. local fallback_root_files = {
  397. "build.gradle", -- Gradle
  398. "build.gradle.kts", -- Gradle
  399. }
  400. return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
  401. end,
  402. },
  403. },
  404. },
  405. lua = {
  406. formatter = {
  407. exe = "stylua",
  408. args = {},
  409. },
  410. linters = { "luacheck" },
  411. lsp = {
  412. provider = "sumneko_lua",
  413. setup = {
  414. cmd = {
  415. DATA_PATH .. "/lspinstall/lua/sumneko-lua-language-server",
  416. "-E",
  417. DATA_PATH .. "/lspinstall/lua/main.lua",
  418. },
  419. on_attach = common_on_attach,
  420. settings = {
  421. Lua = {
  422. runtime = {
  423. -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
  424. version = "LuaJIT",
  425. -- Setup your lua path
  426. path = vim.split(package.path, ";"),
  427. },
  428. diagnostics = {
  429. -- Get the language server to recognize the `vim` global
  430. globals = { "vim", "O" },
  431. },
  432. workspace = {
  433. -- Make the server aware of Neovim runtime files
  434. library = {
  435. [vim.fn.expand "~/.local/share/lunarvim/lvim/lua"] = true,
  436. [vim.fn.expand "$VIMRUNTIME/lua"] = true,
  437. [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
  438. },
  439. maxPreload = 100000,
  440. preloadFileSize = 1000,
  441. },
  442. },
  443. },
  444. },
  445. },
  446. },
  447. php = {
  448. formatter = {
  449. exe = "phpcbf",
  450. args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) },
  451. },
  452. linters = {},
  453. lsp = {
  454. provider = "intelephense",
  455. setup = {
  456. cmd = {
  457. DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense",
  458. "--stdio",
  459. },
  460. on_attach = common_on_attach,
  461. filetypes = { "php", "phtml" },
  462. settings = {
  463. intelephense = {
  464. environment = {
  465. phpVersion = "7.4",
  466. },
  467. },
  468. },
  469. },
  470. },
  471. },
  472. javascript = {
  473. -- @usage can be prettier or eslint
  474. formatter = {
  475. exe = "prettier",
  476. args = {},
  477. },
  478. linters = {
  479. "eslint",
  480. },
  481. lsp = {
  482. provider = "tsserver",
  483. setup = {
  484. cmd = {
  485. -- TODO:
  486. DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
  487. "--stdio",
  488. },
  489. on_attach = require("lsp").common_on_attach,
  490. capabilities = require("lsp").common_capabilities(),
  491. },
  492. },
  493. },
  494. javascriptreact = {
  495. -- @usage can be prettier or eslint
  496. formatter = {
  497. exe = "prettier",
  498. args = {},
  499. },
  500. linters = {
  501. "eslint",
  502. },
  503. lsp = {
  504. provider = "tsserver",
  505. setup = {
  506. cmd = {
  507. -- TODO:
  508. DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
  509. "--stdio",
  510. },
  511. on_attach = require("lsp").common_on_attach,
  512. capabilities = require("lsp").common_capabilities(),
  513. },
  514. },
  515. },
  516. python = {
  517. -- @usage can be flake8 or yapf
  518. formatter = {
  519. exe = "black",
  520. args = {},
  521. },
  522. linters = {
  523. "flake8",
  524. "pylint",
  525. "mypy",
  526. },
  527. lsp = {
  528. provider = "pyright",
  529. setup = {
  530. cmd = {
  531. DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
  532. "--stdio",
  533. },
  534. on_attach = common_on_attach,
  535. capabilities = common_capabilities,
  536. },
  537. },
  538. },
  539. -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")'
  540. -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")'
  541. r = {
  542. formatter = {
  543. exe = "R",
  544. args = {
  545. "--slave",
  546. "--no-restore",
  547. "--no-save",
  548. '-e "formatR::tidy_source(text=readr::read_file(file(\\"stdin\\")), arrow=FALSE)"',
  549. },
  550. stdin = true,
  551. },
  552. lsp = {
  553. provider = "r_language_server",
  554. setup = {
  555. cmd = {
  556. "R",
  557. "--slave",
  558. "-e",
  559. "languageserver::run()",
  560. },
  561. on_attach = common_on_attach,
  562. capabilities = common_capabilities,
  563. },
  564. },
  565. },
  566. ruby = {
  567. formatter = {
  568. exe = "rufo",
  569. args = { "-x" },
  570. stdin = true,
  571. },
  572. linters = { "ruby" },
  573. lsp = {
  574. provider = "solargraph",
  575. setup = {
  576. cmd = {
  577. DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph",
  578. "stdio",
  579. },
  580. on_attach = common_on_attach,
  581. capabilities = common_capabilities,
  582. },
  583. },
  584. },
  585. rust = {
  586. formatter = {
  587. exe = "rustfmt",
  588. args = { "--emit=stdout", "--edition=2018" },
  589. stdin = true,
  590. },
  591. lsp = {
  592. provider = "rust_analyzer",
  593. setup = {
  594. cmd = {
  595. DATA_PATH .. "/lspinstall/rust/rust-analyzer",
  596. },
  597. on_attach = common_on_attach,
  598. capabilities = common_capabilities,
  599. },
  600. },
  601. },
  602. sh = {
  603. -- @usage can be 'shfmt'
  604. formatter = {
  605. exe = "shfmt",
  606. args = {},
  607. },
  608. -- @usage can be 'shellcheck'
  609. linters = { "shellcheck" },
  610. lsp = {
  611. provider = "bashls",
  612. setup = {
  613. cmd = {
  614. DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server",
  615. "start",
  616. },
  617. on_attach = common_on_attach,
  618. capabilities = common_capabilities,
  619. },
  620. },
  621. },
  622. svelte = {
  623. lsp = {
  624. provider = "svelte",
  625. setup = {
  626. cmd = {
  627. DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver",
  628. "--stdio",
  629. },
  630. on_attach = common_on_attach,
  631. capabilities = common_capabilities,
  632. },
  633. },
  634. },
  635. swift = {
  636. formatter = {
  637. exe = "swiftformat",
  638. args = {},
  639. stdin = true,
  640. },
  641. lsp = {
  642. provider = "sourcekit",
  643. setup = {
  644. cmd = {
  645. "xcrun",
  646. "sourcekit-lsp",
  647. },
  648. on_attach = common_on_attach,
  649. capabilities = common_capabilities,
  650. },
  651. },
  652. },
  653. tailwindcss = {
  654. active = false,
  655. filetypes = {
  656. "html",
  657. "css",
  658. "scss",
  659. "javascript",
  660. "javascriptreact",
  661. "typescript",
  662. "typescriptreact",
  663. },
  664. },
  665. terraform = {
  666. formatter = {
  667. exe = "terraform",
  668. args = { "fmt" },
  669. stdin = false,
  670. },
  671. lsp = {
  672. provider = "terraformls",
  673. setup = {
  674. cmd = {
  675. DATA_PATH .. "/lspinstall/terraform/terraform-ls",
  676. "serve",
  677. },
  678. on_attach = common_on_attach,
  679. capabilities = common_capabilities,
  680. },
  681. },
  682. },
  683. typescript = {
  684. -- @usage can be prettier or eslint
  685. formatter = {
  686. exe = "prettier",
  687. args = {},
  688. },
  689. linters = {
  690. "eslint",
  691. },
  692. lsp = {
  693. provider = "tsserver",
  694. setup = {
  695. cmd = {
  696. -- TODO:
  697. DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
  698. "--stdio",
  699. },
  700. on_attach = require("lsp").common_on_attach,
  701. capabilities = require("lsp").common_capabilities(),
  702. },
  703. },
  704. },
  705. typescriptreact = {
  706. -- @usage can be prettier or eslint
  707. formatter = {
  708. exe = "prettier",
  709. args = {},
  710. },
  711. linters = {
  712. "eslint",
  713. },
  714. lsp = {
  715. provider = "tsserver",
  716. setup = {
  717. cmd = {
  718. -- TODO:
  719. DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
  720. "--stdio",
  721. },
  722. on_attach = require("lsp").common_on_attach,
  723. capabilities = require("lsp").common_capabilities(),
  724. },
  725. },
  726. },
  727. vim = {
  728. formatter = {
  729. exe = "",
  730. args = {},
  731. },
  732. linters = { "" },
  733. lsp = {
  734. provider = "vimls",
  735. setup = {
  736. cmd = {
  737. DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server",
  738. "--stdio",
  739. },
  740. on_attach = common_on_attach,
  741. capabilities = common_capabilities,
  742. },
  743. },
  744. },
  745. vue = {
  746. formatter = {
  747. exe = "prettier",
  748. args = {
  749. "--stdin-filepath",
  750. "${FILEPATH}",
  751. },
  752. stdin = true,
  753. },
  754. lsp = {
  755. provider = "vetur",
  756. setup = {
  757. cmd = {
  758. DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls",
  759. },
  760. on_attach = common_on_attach,
  761. capabilities = common_capabilities,
  762. },
  763. },
  764. },
  765. yaml = {
  766. formatter = {
  767. exe = "prettier",
  768. args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
  769. stdin = true,
  770. },
  771. lsp = {
  772. provider = "yamlls",
  773. setup = {
  774. cmd = {
  775. DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server",
  776. "--stdio",
  777. },
  778. on_attach = common_on_attach,
  779. capabilities = common_capabilities,
  780. },
  781. },
  782. },
  783. zig = {
  784. formatter = {
  785. exe = "zig",
  786. args = { "fmt" },
  787. stdin = false,
  788. },
  789. lsp = {
  790. provider = "zls",
  791. setup = {
  792. cmd = {
  793. "zls",
  794. },
  795. on_attach = common_on_attach,
  796. capabilities = common_capabilities,
  797. },
  798. },
  799. },
  800. }
  801. require("core.which-key").config()
  802. require "core.status_colors"
  803. require("core.gitsigns").config()
  804. require("core.compe").config()
  805. require("core.dashboard").config()
  806. require("core.dap").config()
  807. require("core.terminal").config()
  808. require("core.telescope").config()
  809. require("core.treesitter").config()
  810. require("core.nvimtree").config()