default-config.lua 19 KB

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