default-config.lua 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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. python = {
  492. -- @usage can be flake8 or yapf
  493. formatter = {
  494. exe = "black",
  495. args = {},
  496. },
  497. linters = {
  498. "flake8",
  499. "pylint",
  500. "mypy",
  501. },
  502. lsp = {
  503. provider = "pyright",
  504. setup = {
  505. cmd = {
  506. DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
  507. "--stdio",
  508. },
  509. on_attach = common_on_attach,
  510. capabilities = common_capabilities,
  511. },
  512. },
  513. },
  514. -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")'
  515. -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")'
  516. r = {
  517. formatter = {
  518. exe = "R",
  519. args = {
  520. "--slave",
  521. "--no-restore",
  522. "--no-save",
  523. '-e "formatR::tidy_source(text=readr::read_file(file(\\"stdin\\")), arrow=FALSE)"',
  524. },
  525. stdin = true,
  526. },
  527. lsp = {
  528. provider = "r_language_server",
  529. setup = {
  530. cmd = {
  531. "R",
  532. "--slave",
  533. "-e",
  534. "languageserver::run()",
  535. },
  536. on_attach = common_on_attach,
  537. capabilities = common_capabilities,
  538. },
  539. },
  540. },
  541. ruby = {
  542. formatter = {
  543. exe = "rufo",
  544. args = { "-x" },
  545. stdin = true,
  546. },
  547. linters = { "ruby" },
  548. lsp = {
  549. provider = "solargraph",
  550. setup = {
  551. cmd = {
  552. DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph",
  553. "stdio",
  554. },
  555. on_attach = common_on_attach,
  556. capabilities = common_capabilities,
  557. },
  558. },
  559. },
  560. rust = {
  561. formatter = {
  562. exe = "rustfmt",
  563. args = { "--emit=stdout", "--edition=2018" },
  564. stdin = true,
  565. },
  566. lsp = {
  567. provider = "rust_analyzer",
  568. setup = {
  569. cmd = {
  570. DATA_PATH .. "/lspinstall/rust/rust-analyzer",
  571. },
  572. on_attach = common_on_attach,
  573. capabilities = common_capabilities,
  574. },
  575. },
  576. },
  577. sh = {
  578. -- @usage can be 'shfmt'
  579. formatter = {
  580. exe = "shfmt",
  581. args = {},
  582. },
  583. -- @usage can be 'shellcheck'
  584. linters = { "shellcheck" },
  585. lsp = {
  586. provider = "bashls",
  587. setup = {
  588. cmd = {
  589. DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server",
  590. "start",
  591. },
  592. on_attach = common_on_attach,
  593. capabilities = common_capabilities,
  594. },
  595. },
  596. },
  597. svelte = {
  598. lsp = {
  599. provider = "svelte",
  600. setup = {
  601. cmd = {
  602. DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver",
  603. "--stdio",
  604. },
  605. on_attach = common_on_attach,
  606. capabilities = common_capabilities,
  607. },
  608. },
  609. },
  610. swift = {
  611. formatter = {
  612. exe = "swiftformat",
  613. args = {},
  614. stdin = true,
  615. },
  616. lsp = {
  617. provider = "sourcekit",
  618. setup = {
  619. cmd = {
  620. "xcrun",
  621. "sourcekit-lsp",
  622. },
  623. on_attach = common_on_attach,
  624. capabilities = common_capabilities,
  625. },
  626. },
  627. },
  628. tailwindcss = {
  629. active = false,
  630. filetypes = {
  631. "html",
  632. "css",
  633. "scss",
  634. "javascript",
  635. "javascriptreact",
  636. "typescript",
  637. "typescriptreact",
  638. },
  639. },
  640. terraform = {
  641. formatter = {
  642. exe = "terraform",
  643. args = { "fmt" },
  644. stdin = false,
  645. },
  646. lsp = {
  647. provider = "terraformls",
  648. setup = {
  649. cmd = {
  650. DATA_PATH .. "/lspinstall/terraform/terraform-ls",
  651. "serve",
  652. },
  653. on_attach = common_on_attach,
  654. capabilities = common_capabilities,
  655. },
  656. },
  657. },
  658. vim = {
  659. linters = { "vint" },
  660. lsp = {
  661. provider = "vimls",
  662. setup = {
  663. cmd = {
  664. DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server",
  665. "--stdio",
  666. },
  667. on_attach = common_on_attach,
  668. capabilities = common_capabilities,
  669. },
  670. },
  671. },
  672. vue = {
  673. formatter = {
  674. exe = "prettier",
  675. args = {
  676. "--stdin-filepath",
  677. "${FILEPATH}",
  678. },
  679. stdin = true,
  680. },
  681. lsp = {
  682. provider = "vetur",
  683. setup = {
  684. cmd = {
  685. DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls",
  686. },
  687. on_attach = common_on_attach,
  688. capabilities = common_capabilities,
  689. },
  690. },
  691. },
  692. yaml = {
  693. formatter = {
  694. exe = "prettier",
  695. args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
  696. stdin = true,
  697. },
  698. lsp = {
  699. provider = "yamlls",
  700. setup = {
  701. cmd = {
  702. DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server",
  703. "--stdio",
  704. },
  705. on_attach = common_on_attach,
  706. capabilities = common_capabilities,
  707. },
  708. },
  709. },
  710. zig = {
  711. formatter = {
  712. exe = "zig",
  713. args = { "fmt" },
  714. stdin = false,
  715. },
  716. lsp = {
  717. provider = "zls",
  718. setup = {
  719. cmd = {
  720. "zls",
  721. },
  722. on_attach = common_on_attach,
  723. capabilities = common_capabilities,
  724. },
  725. },
  726. },
  727. }
  728. require("core.which-key").config()
  729. require "core.status_colors"
  730. require("core.gitsigns").config()
  731. require("core.compe").config()
  732. require("core.dashboard").config()
  733. require("core.dap").config()
  734. require("core.terminal").config()
  735. require("core.telescope").config()
  736. require("core.treesitter").config()
  737. require("core.nvimtree").config()