default-config.lua 19 KB

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