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