default-config.lua 19 KB

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