diff --git a/README.md b/README.md index 6077256c..080d19d2 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,10 @@ Example: -- O.format_on_save = false -- to disbale formatting on save -- O.lint_on_save = false -- to disable formatting on save O.completion.autocomplete = true -O.default_options.relativenumber = true O.colorscheme = 'spacegray' -O.default_options.timeoutlen = 100 -- keymappings -O.keys.leader_key = "space" +O.leader = "space" -- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them O.keys.normal_mode = { -- Page down/up @@ -101,7 +99,6 @@ vim.api.nvim_set_keymap("i", "", "compe#complete()", { noremap = true, -- After changing plugin config it is recommended to run :PackerCompile O.plugin.dashboard.active = true O.plugin.terminal.active = true -O.plugin.zen.active = true -- if you don't want all the parsers change this to a table of the ones you want O.treesitter.ensure_installed = "all" @@ -142,7 +139,7 @@ O.lang.python.analysis.use_library_code_types = true -- O.lang.formatter.go.exe = "goimports" -- Additional Plugins --- O.user_plugins = { +-- O.plugins = { -- {"folke/tokyonight.nvim"}, -- { -- "ray-x/lsp_signature.nvim", @@ -156,16 +153,9 @@ O.lang.python.analysis.use_library_code_types = true -- } -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- O.autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} --- Additional Leader bindings for WhichKey --- O.user_which_key = { --- A = { --- name = "+Custom Leader Keys", --- a = { "echo 'first custom command'", "Description for a" }, --- b = { "echo 'second custom command'", "Description for b" }, --- }, --- } +-- TODO Additional Leader bindings for WhichKey -- To link your init.vim (until you find Lua replacements) -- vim.cmd('source ' .. CONFIG_PATH .. '/lua/lv-user/init.vim') diff --git a/ftplugin/c.lua b/ftplugin/c.lua index c4fbdd16..3f931e4a 100644 --- a/ftplugin/c.lua +++ b/ftplugin/c.lua @@ -1,4 +1,4 @@ -require("lang.clang").format() -require("lang.clang").lint() -require("lang.clang").lsp() -require("lang.clang").dap() +require("lsp").setup "c" + +-- TODO get from dap +-- require("lang.c").dap() diff --git a/ftplugin/clojure.lua b/ftplugin/clojure.lua index 17d79724..683720a5 100644 --- a/ftplugin/clojure.lua +++ b/ftplugin/clojure.lua @@ -1,4 +1 @@ -require("lang.clojure").format() -require("lang.clojure").lint() -require("lang.clojure").lsp() -require("lang.clojure").dap() +require("lsp").setup "clojure" diff --git a/ftplugin/cmake.lua b/ftplugin/cmake.lua index 8d50c595..56d30106 100644 --- a/ftplugin/cmake.lua +++ b/ftplugin/cmake.lua @@ -1,4 +1 @@ -require("lang.cmake").format() -require("lang.cmake").lint() -require("lang.cmake").lsp() -require("lang.cmake").dap() +require("lsp").setup "cmake" diff --git a/ftplugin/cpp.lua b/ftplugin/cpp.lua deleted file mode 120000 index d2be5311..00000000 --- a/ftplugin/cpp.lua +++ /dev/null @@ -1 +0,0 @@ -c.lua \ No newline at end of file diff --git a/ftplugin/cpp.lua b/ftplugin/cpp.lua new file mode 100644 index 00000000..6028ea49 --- /dev/null +++ b/ftplugin/cpp.lua @@ -0,0 +1 @@ +require("lsp").setup "cpp" diff --git a/ftplugin/cs.lua b/ftplugin/cs.lua index cf2e31c6..dd76f973 100644 --- a/ftplugin/cs.lua +++ b/ftplugin/cs.lua @@ -1,4 +1 @@ -require("lang.cs").format() -require("lang.cs").lint() -require("lang.cs").lsp() -require("lang.cs").dap() +require("lsp").setup "csharp" diff --git a/ftplugin/css.lua b/ftplugin/css.lua index 846c6a83..094ed2a3 100644 --- a/ftplugin/css.lua +++ b/ftplugin/css.lua @@ -1,4 +1 @@ -require("lang.css").format() -require("lang.css").lint() -require("lang.css").lsp() -require("lang.css").dap() +require("lsp").setup "css" diff --git a/ftplugin/dart.lua b/ftplugin/dart.lua index 1db4fe05..9f0ccfa0 100644 --- a/ftplugin/dart.lua +++ b/ftplugin/dart.lua @@ -1,4 +1 @@ -require("lang.dart").format() -require("lang.dart").lint() -require("lang.dart").lsp() -require("lang.dart").dap() +require("lsp").setup "dart" diff --git a/ftplugin/dockerfile.lua b/ftplugin/dockerfile.lua index 8a43c764..72ec7f90 100644 --- a/ftplugin/dockerfile.lua +++ b/ftplugin/dockerfile.lua @@ -1,4 +1 @@ -require("lang.dockerfile").format() -require("lang.dockerfile").lint() -require("lang.dockerfile").lsp() -require("lang.dockerfile").dap() +require("lsp").setup "docker" diff --git a/ftplugin/elixir.lua b/ftplugin/elixir.lua index 07b9625b..f16f71fa 100644 --- a/ftplugin/elixir.lua +++ b/ftplugin/elixir.lua @@ -1,4 +1,9 @@ -require("lang.elixir").format() -require("lang.elixir").lint() -require("lang.elixir").lsp() -require("lang.elixir").dap() +require("lsp").setup "elixir" + +-- TODO: do we need this? +-- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) +-- vim.cmd [[ +-- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir +-- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir +-- au BufRead,BufNewFile mix.lock set filetype=elixir +-- ]] diff --git a/ftplugin/elm.lua b/ftplugin/elm.lua index 0868b9db..38fda314 100644 --- a/ftplugin/elm.lua +++ b/ftplugin/elm.lua @@ -1,4 +1 @@ -require("lang.elm").format() -require("lang.elm").lint() -require("lang.elm").lsp() -require("lang.elm").dap() +require("lsp").setup "elm" diff --git a/ftplugin/erlang.lua b/ftplugin/erlang.lua index b7231c41..c6426dba 100644 --- a/ftplugin/erlang.lua +++ b/ftplugin/erlang.lua @@ -1,4 +1 @@ -require("lang.erlang").format() -require("lang.erlang").lint() -require("lang.erlang").lsp() -require("lang.erlang").dap() +require("lsp").setup "erlang" diff --git a/ftplugin/euphoria3.lua b/ftplugin/euphoria3.lua index 67da6c48..391c51ad 100644 --- a/ftplugin/euphoria3.lua +++ b/ftplugin/euphoria3.lua @@ -1,4 +1,9 @@ -require("lang.euphoria3").format() -require("lang.euphoria3").lint() -require("lang.euphoria3").lsp() -require("lang.euphoria3").dap() +require("lsp").setup "erlang" + +-- TODO: do we need this? +-- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) +-- vim.cmd [[ +-- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir +-- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir +-- au BufRead,BufNewFile mix.lock set filetype=elixir +-- ]] diff --git a/ftplugin/fish.lua b/ftplugin/fish.lua index 00416a08..575ec434 100644 --- a/ftplugin/fish.lua +++ b/ftplugin/fish.lua @@ -1,4 +1 @@ -require("lang.fish").format() -require("lang.fish").lint() -require("lang.fish").lsp() -require("lang.fish").dap() +require("lsp").setup "fish" diff --git a/ftplugin/go.lua b/ftplugin/go.lua index e5b8475f..218b634c 100644 --- a/ftplugin/go.lua +++ b/ftplugin/go.lua @@ -1,4 +1 @@ -require("lang.go").format() -require("lang.go").lint() -require("lang.go").lsp() -require("lang.go").dap() +require("lsp").setup "go" diff --git a/ftplugin/graphql.lua b/ftplugin/graphql.lua index 30bddcc4..83e8878d 100644 --- a/ftplugin/graphql.lua +++ b/ftplugin/graphql.lua @@ -1,4 +1 @@ -require("lang.graphql").format() -require("lang.graphql").lint() -require("lang.graphql").lsp() -require("lang.graphql").dap() +require("lsp").setup "graphql" diff --git a/ftplugin/html.lua b/ftplugin/html.lua index 70c3295a..c60394c0 100644 --- a/ftplugin/html.lua +++ b/ftplugin/html.lua @@ -1,4 +1 @@ -require("lang.html").format() -require("lang.html").lint() -require("lang.html").lsp() -require("lang.html").dap() +require("lsp").setup "html" diff --git a/ftplugin/java.lua b/ftplugin/java.lua index 898cf8af..dcb46ca2 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -1,4 +1 @@ -require("lang.java").format() -require("lang.java").lint() -require("lang.java").lsp() -require("lang.java").dap() +require("lsp").setup "java" diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua index fc59ab68..37b95c71 100644 --- a/ftplugin/javascript.lua +++ b/ftplugin/javascript.lua @@ -1 +1 @@ -require "lsp.tsserver-ls" +require("lsp").setup "javascript" diff --git a/ftplugin/javascriptreact.lua b/ftplugin/javascriptreact.lua index f74b54e9..90920166 100644 --- a/ftplugin/javascriptreact.lua +++ b/ftplugin/javascriptreact.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "javascriptreact" diff --git a/ftplugin/json.lua b/ftplugin/json.lua index 0408f9b5..18368cf9 100644 --- a/ftplugin/json.lua +++ b/ftplugin/json.lua @@ -1,4 +1 @@ -require("lang.json").format() -require("lang.json").lint() -require("lang.json").lsp() -require("lang.json").dap() +require("lsp").setup "json" diff --git a/ftplugin/julia.lua b/ftplugin/julia.lua index 7e16d7bd..9840be1f 100644 --- a/ftplugin/julia.lua +++ b/ftplugin/julia.lua @@ -1,4 +1 @@ -require("lang.julia").format() -require("lang.julia").lint() -require("lang.julia").lsp() -require("lang.julia").dap() +require("lsp").setup "julia" diff --git a/ftplugin/kotlin.lua b/ftplugin/kotlin.lua index 2677c287..a0e6d5d6 100644 --- a/ftplugin/kotlin.lua +++ b/ftplugin/kotlin.lua @@ -1,4 +1 @@ -require("lang.kotlin").format() -require("lang.kotlin").lint() -require("lang.kotlin").lsp() -require("lang.kotlin").dap() +require("lsp").setup "kotlin" diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua index 37ebab42..2ed88315 100644 --- a/ftplugin/lua.lua +++ b/ftplugin/lua.lua @@ -1,4 +1 @@ -require("lang.lua").format() -require("lang.lua").lint() -require("lang.lua").lsp() -require("lang.lua").dap() +require("lsp").setup "lua" diff --git a/ftplugin/php.lua b/ftplugin/php.lua index c319ea67..4eabcf71 100644 --- a/ftplugin/php.lua +++ b/ftplugin/php.lua @@ -1,4 +1 @@ -require("lang.php").format() -require("lang.php").lint() -require("lang.php").lsp() -require("lang.php").dap() +require("lsp").setup "php" diff --git a/ftplugin/python.lua b/ftplugin/python.lua index 85f08beb..3e79e6bc 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1,4 +1,3 @@ -require("lang.python").format() -require("lang.python").lint() -require("lang.python").lsp() -require("lang.python").dap() +require("lsp").setup "python" +-- TODO get from dap +-- require("lang.python").dap() diff --git a/ftplugin/r.lua b/ftplugin/r.lua index 6de40bda..296d3c86 100644 --- a/ftplugin/r.lua +++ b/ftplugin/r.lua @@ -1,4 +1,2 @@ -require("lang.r").format() -require("lang.r").lint() -require("lang.r").lsp() -require("lang.r").dap() +-- R -e 'install.packages("languageserver",repos = "http://cran.us.r-project.org")' +require("lsp").setup "r" diff --git a/ftplugin/ruby.lua b/ftplugin/ruby.lua index 6022504c..7e968917 100644 --- a/ftplugin/ruby.lua +++ b/ftplugin/ruby.lua @@ -1,4 +1,2 @@ -require("lang.ruby").format() -require("lang.ruby").lint() -require("lang.ruby").lsp() -require("lang.ruby").dap() +-- also support sorbet +require("lsp").setup "ruby" diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index 74728407..f1623f25 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -1,4 +1,4 @@ -require("lang.rust").format() -require("lang.rust").lint() -require("lang.rust").lsp() -require("lang.rust").dap() +require("lsp").setup "rust" + +-- TODO get from dap +-- require("lang.rust").dap() diff --git a/ftplugin/scala.lua b/ftplugin/scala.lua index 3b726fb6..169e36ad 100644 --- a/ftplugin/scala.lua +++ b/ftplugin/scala.lua @@ -1,4 +1 @@ -require("lang.scala").format() -require("lang.scala").lint() -require("lang.scala").lsp() -require("lang.scala").dap() +require("lsp").setup "scala" diff --git a/ftplugin/sh.lua b/ftplugin/sh.lua index ee3a27d7..4f18fbca 100644 --- a/ftplugin/sh.lua +++ b/ftplugin/sh.lua @@ -1,4 +1 @@ -require("lang.sh").format() -require("lang.sh").lint() -require("lang.sh").lsp() -require("lang.sh").dap() +require("lsp").setup "sh" diff --git a/ftplugin/svelte.lua b/ftplugin/svelte.lua index 108a0fc3..175a5cbd 100644 --- a/ftplugin/svelte.lua +++ b/ftplugin/svelte.lua @@ -1,4 +1 @@ -require("lang.svelte").format() -require("lang.svelte").lint() -require("lang.svelte").lsp() -require("lang.svelte").dap() +require("lsp").setup "svelte" diff --git a/ftplugin/swift.lua b/ftplugin/swift.lua index 64d87e1c..1ae7554a 100644 --- a/ftplugin/swift.lua +++ b/ftplugin/swift.lua @@ -1,4 +1 @@ -require("lang.swift").format() -require("lang.swift").lint() -require("lang.swift").lsp() -require("lang.swift").dap() +require("lsp").setup "swift" diff --git a/ftplugin/tex.lua b/ftplugin/tex.lua index 3de774f4..e9a98ec5 100644 --- a/ftplugin/tex.lua +++ b/ftplugin/tex.lua @@ -1,4 +1 @@ -require("lang.tex").format() -require("lang.tex").lint() -require("lang.tex").lsp() -require("lang.tex").dap() +require("lsp").setup "tex" diff --git a/ftplugin/tf.lua b/ftplugin/tf.lua index cfe54936..3486663d 100644 --- a/ftplugin/tf.lua +++ b/ftplugin/tf.lua @@ -1,4 +1 @@ -require("lang.terraform").format() -require("lang.terraform").lint() -require("lang.terraform").lsp() -require("lang.terraform").dap() +require("lsp").setup "terraform" diff --git a/ftplugin/typescript.lua b/ftplugin/typescript.lua index f74b54e9..2f6219df 100644 --- a/ftplugin/typescript.lua +++ b/ftplugin/typescript.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "typescript" diff --git a/ftplugin/typescriptreact.lua b/ftplugin/typescriptreact.lua index f74b54e9..2f6219df 100644 --- a/ftplugin/typescriptreact.lua +++ b/ftplugin/typescriptreact.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "typescript" diff --git a/ftplugin/vim.lua b/ftplugin/vim.lua index 0b5f5ea8..88c00c1c 100644 --- a/ftplugin/vim.lua +++ b/ftplugin/vim.lua @@ -1,4 +1 @@ -require("lang.vim").format() -require("lang.vim").lint() -require("lang.vim").lsp() -require("lang.vim").dap() +require("lsp").setup "vim" diff --git a/ftplugin/vue.lua b/ftplugin/vue.lua index 11d7b2a1..a174c9bf 100644 --- a/ftplugin/vue.lua +++ b/ftplugin/vue.lua @@ -1,4 +1 @@ -require("lang.vue").format() -require("lang.vue").lint() -require("lang.vue").lsp() -require("lang.vue").dap() +require("lsp").setup "vue" diff --git a/ftplugin/yaml.lua b/ftplugin/yaml.lua index f38f2586..d21f9785 100644 --- a/ftplugin/yaml.lua +++ b/ftplugin/yaml.lua @@ -1,4 +1 @@ -require("lang.yaml").format() -require("lang.yaml").lint() -require("lang.yaml").lsp() -require("lang.yaml").dap() +require("lsp").setup "yaml" diff --git a/ftplugin/zig.lua b/ftplugin/zig.lua index 9b391764..ef3d64d4 100644 --- a/ftplugin/zig.lua +++ b/ftplugin/zig.lua @@ -1,4 +1 @@ -require("lang.zig").format() -require("lang.zig").lint() -require("lang.zig").lsp() -require("lang.zig").dap() +require("lsp").setup "zig" diff --git a/ftplugin/zsh.lua b/ftplugin/zsh.lua index 4dfbb7b8..4f18fbca 100644 --- a/ftplugin/zsh.lua +++ b/ftplugin/zsh.lua @@ -1,4 +1 @@ -require("lang.zsh").format() -require("lang.zsh").lint() -require("lang.zsh").lsp() -require("lang.zsh").dap() +require("lsp").setup "sh" diff --git a/init.lua b/init.lua index 2e3a5d32..73f0a325 100644 --- a/init.lua +++ b/init.lua @@ -7,10 +7,12 @@ vim.cmd [[ set runtimepath-=~/.config/nvim set runtimepath-=~/.config/nvim/after - set runtimepath^=~/.config/lvim + set runtimepath+=~/.config/lvim + set runtimepath^=~/.local/share/lunarvim/lvim/after ]] -- vim.opt.rtp:append() instead of vim.cmd ? require "default-config" +require "settings" local status_ok, error = pcall(vim.cmd, "luafile ~/.config/lvim/lv-config.lua") if not status_ok then print "something is wrong with your lv-config" @@ -21,17 +23,30 @@ require "keymappings" local plugins = require "plugins" local plugin_loader = require("plugin-loader").init() -plugin_loader:load { plugins, O.user_plugins } -vim.g.colors_name = O.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs. -vim.cmd("colorscheme " .. O.colorscheme) +plugin_loader:load { plugins, lvim.plugins } +vim.g.colors_name = lvim.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs. +vim.cmd("colorscheme " .. lvim.colorscheme) -require "settings" -require "lv-utils" +local utils = require "lv-utils" +utils.toggle_autoformat() +require("lsp").setup_handlers() + +local null_status_ok, null_ls = pcall(require, "null-ls") +if null_status_ok then + null_ls.config {} + require("lspconfig")["null-ls"].setup {} +end + +local lsp_settings_status_ok, lsp_settings = pcall(require, "nlspsettings") +if lsp_settings_status_ok then + lsp_settings.setup { + config_home = os.getenv "HOME" .. "/.config/lvim/lsp-settings", + } +end -- TODO: these guys need to be in language files --- require "lsp" --- if O.lang.emmet.active then +-- if lvim.lang.emmet.active then -- require "lsp.emmet-ls" -- end --- if O.lang.tailwindcss.active then +-- if lvim.lang.tailwindcss.active then -- require "lsp.tailwind diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index d4e4b4fe..ef1d4780 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -3,7 +3,7 @@ vim.api.nvim_set_keymap("n", "", ":BufferNext", { noremap = true, silen vim.api.nvim_set_keymap("n", "", ":BufferPrevious", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "c", ":BufferClose", { noremap = true, silent = true }) -O.plugin.which_key.mappings["b"] = { +lvim.builtin.which_key.mappings["b"] = { name = "Buffers", j = { "BufferPick", "jump to buffer" }, f = { "Telescope buffers", "Find buffer" }, diff --git a/lua/core/compe.lua b/lua/core/compe.lua index c8152ad1..a3521cfe 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.completion = { + lvim.completion = { enabled = true, autocomplete = true, debug = false, @@ -34,14 +34,14 @@ M.config = function() end M.setup = function() - vim.g.vsnip_snippet_dir = O.vsnip_dir + vim.g.vsnip_snippet_dir = lvim.vsnip_dir local status_ok, compe = pcall(require, "compe") if not status_ok then return end - compe.setup(O.completion) + compe.setup(lvim.completion) local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) diff --git a/lua/core/dap.lua b/lua/core/dap.lua index bc76e221..30e3aef9 100644 --- a/lua/core/dap.lua +++ b/lua/core/dap.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.plugin.dap = { + lvim.builtin.dap = { active = false, breakpoint = { text = "", @@ -17,10 +17,10 @@ M.setup = function() return end - vim.fn.sign_define("DapBreakpoint", O.plugin.dap.breakpoint) + vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint) dap.defaults.fallback.terminal_win_cmd = "50vsplit new" - O.user_which_key["d"] = { + lvim.builtin.which_key.mappings["d"] = { name = "Debug", t = { "lua require'dap'.toggle_breakpoint()", "Toggle Breakpoint" }, b = { "lua require'dap'.step_back()", "Step Back" }, @@ -38,4 +38,21 @@ M.setup = function() } end +-- TODO put this up there ^^^ call in ftplugin + +-- M.dap = function() +-- if lvim.plugin.dap.active then +-- local dap_install = require "dap-install" +-- dap_install.config("python_dbg", {}) +-- end +-- end +-- +-- M.dap = function() +-- -- gem install readapt ruby-debug-ide +-- if lvim.plugin.dap.active then +-- local dap_install = require "dap-install" +-- dap_install.config("ruby_vsc_dbg", {}) +-- end +-- end + return M diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index a1af5319..7433f2d6 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.plugin.dashboard = { + lvim.builtin.dashboard = { active = false, search_handler = "telescope", custom_header = { @@ -55,13 +55,13 @@ end M.setup = function() vim.g.dashboard_disable_at_vimenter = 0 - vim.g.dashboard_custom_header = O.plugin.dashboard.custom_header + vim.g.dashboard_custom_header = lvim.builtin.dashboard.custom_header - vim.g.dashboard_default_executive = O.plugin.dashboard.search_handler + vim.g.dashboard_default_executive = lvim.builtin.dashboard.search_handler - vim.g.dashboard_custom_section = O.plugin.dashboard.custom_section + vim.g.dashboard_custom_section = lvim.builtin.dashboard.custom_section - O.plugin.which_key.mappings[";"] = { "Dashboard", "Dashboard" } + lvim.builtin.which_key.mappings[";"] = { "Dashboard", "Dashboard" } -- f = { -- description = { " Neovim Config Files" }, @@ -81,7 +81,7 @@ M.setup = function() -- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'}, -- vim.g.dashboard_session_directory = CACHE_PATH..'/session' - -- vim.g.dashboard_custom_footer = O.dashboard.footer + -- vim.g.dashboard_custom_footer = lvim.dashboard.footer require("lv-utils").define_augroups { _dashboard = { -- seems to be nobuflisted that makes my stuff disapear will do more testing @@ -93,7 +93,7 @@ M.setup = function() { "FileType", "dashboard", - "set showtabline=0 | autocmd BufLeave set showtabline=" .. O.default_options.showtabline, + "set showtabline=0 | autocmd BufLeave set showtabline=" .. vim.opt.showtabline._value, }, { "FileType", "dashboard", "nnoremap q :q" }, }, diff --git a/lua/core/formatter.lua b/lua/core/formatter.lua deleted file mode 100644 index c8f1baeb..00000000 --- a/lua/core/formatter.lua +++ /dev/null @@ -1,60 +0,0 @@ --- autoformat -if O.format_on_save then - require("lv-utils").define_augroups { - autoformat = { - { - "BufWritePost", - "*", - ":silent FormatWrite", - }, - }, - } -end - --- -- check if formatter has been defined for the language or not --- local function formatter_exists(lang_formatter) --- if lang_formatter == nil then --- return false --- end --- if lang_formatter.exe == nil or lang_formatter.args == nil then --- return false --- end --- return true --- end - --- returns default formatter for given language --- local function formatter_return(lang_formatter) --- return { --- exe = lang_formatter.exe, --- args = lang_formatter.args, --- stdin = not (lang_formatter.stdin ~= nil), --- } --- end - --- fill a table like this -> {rust: {exe:"sth",args:{"a","b"},stdin=true},go: {}...} --- local formatter_filetypes = {} --- for k, v in pairs(O.lang) do --- if formatter_exists(v.formatter) then --- local keys = v.filetypes --- if keys == nil then --- keys = { k } --- end --- for _, l in pairs(keys) do --- formatter_filetypes[l] = { --- function() --- return formatter_return(v.formatter) --- end, --- } --- end --- end --- end -local status_ok, _ = pcall(require, "formatter") -if not status_ok then - return -end - -if not O.format_on_save then - vim.cmd [[if exists('#autoformat#BufWritePost') - :autocmd! autoformat - endif]] -end diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index f880e430..8ca6f5c7 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -7,9 +7,9 @@ if not status_ok then end -- NOTE: if someone defines colors but doesn't have them then this will break -local palette_status_ok, colors = pcall(require, O.colorscheme .. ".palette") +local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette") if not palette_status_ok then - colors = O.plugin.galaxyline.colors + colors = lvim.builtin.galaxyline.colors end local condition = require "galaxyline.condition" diff --git a/lua/core/gitsigns.lua b/lua/core/gitsigns.lua index bc310ad6..2a5060be 100644 --- a/lua/core/gitsigns.lua +++ b/lua/core/gitsigns.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.plugin.gitsigns = { + lvim.builtin.gitsigns = { signs = { add = { hl = "GitSignsAdd", @@ -53,7 +53,7 @@ M.setup = function() if not status_ok then return end - gitsigns.setup(O.plugin.gitsigns) + gitsigns.setup(lvim.builtin.gitsigns) end return M diff --git a/lua/core/linter.lua b/lua/core/linter.lua deleted file mode 100644 index 676b0cf7..00000000 --- a/lua/core/linter.lua +++ /dev/null @@ -1,33 +0,0 @@ -local M = {} - -M.setup = function() - if O.lint_on_save then - require("lv-utils").define_augroups { - autolint = { - { - "BufWritePost", - "", - ":silent lua require('lint').try_lint()", - }, - { - "BufEnter", - "", - ":silent lua require('lint').try_lint()", - }, - }, - } - end -end - -local status_ok, _ = pcall(require, "lint") -if not status_ok then - return -end - -if not O.lint_on_save then - vim.cmd [[if exists('#autolint#BufWritePost') - :autocmd! autolint - endif]] -end - -return M diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index a763c71d..62f71d32 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -1,7 +1,7 @@ local M = {} -- M.config = function() - O.plugin.nvimtree = { + lvim.builtin.nvimtree = { side = "left", show_icons = { git = 1, @@ -52,7 +52,7 @@ M.setup = function() end local g = vim.g - for opt, val in pairs(O.plugin.nvimtree) do + for opt, val in pairs(lvim.builtin.nvimtree) do g["nvim_tree_" .. opt] = val end diff --git a/lua/core/status_colors.lua b/lua/core/status_colors.lua index ddb4aa98..37e9d7c9 100644 --- a/lua/core/status_colors.lua +++ b/lua/core/status_colors.lua @@ -1,4 +1,4 @@ -O.plugin.galaxyline = { +lvim.builtin.galaxyline = { active = true, colors = { alt_bg = "#2E2E2E", diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 4456d65e..1e605c7c 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -5,7 +5,7 @@ M.config = function() return end - O.plugin.telescope = { + lvim.builtin.telescope = { active = false, defaults = { find_command = { @@ -89,7 +89,7 @@ M.setup = function() if not status_ok then return end - telescope.setup(O.plugin.telescope) + telescope.setup(lvim.builtin.telescope) vim.api.nvim_set_keymap("n", "f", ":Telescope find_files", { noremap = true, silent = true }) end diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 0f930453..b7c58c0d 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.plugin["terminal"] = { + lvim.builtin["terminal"] = { -- size can be a number or function which is passed the current terminal size = 5, -- open_mapping = [[]], @@ -47,8 +47,8 @@ M.setup = function() "lua require('core.terminal')._lazygit_toggle()", { noremap = true, silent = true } ) - O.plugin.which_key.mappings["gg"] = "LazyGit" - terminal.setup(O.plugin.terminal) + lvim.builtin.which_key.mappings["gg"] = "LazyGit" + terminal.setup(lvim.builtin.terminal) end local function is_installed(exe) diff --git a/lua/core/treesitter.lua b/lua/core/treesitter.lua index 2b7a2d54..c81f0696 100644 --- a/lua/core/treesitter.lua +++ b/lua/core/treesitter.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.treesitter = { + lvim.builtin.treesitter = { ensure_installed = {}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages ignore_install = {}, matchup = { @@ -59,129 +59,15 @@ M.config = function() max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int }, } - - -- -- TODO refactor treesitter - -- -- @usage pass a table with your desired languages - -- treesitter = { - -- ensure_installed = "all", - -- ignore_install = { "haskell" }, - -- highlight = { enabled = true }, - -- -- The below are for treesitter-textobjects plugin - -- textobj_prefixes = { - -- goto_next = "]", -- Go to next - -- goto_previous = "[", -- Go to previous - -- inner = "i", -- Select inside - -- outer = "a", -- Selct around - -- swap = "a", -- Swap with next - -- }, - -- textobj_suffixes = { - -- -- Start and End respectively for the goto keys - -- -- for other keys it only uses the first - -- ["function"] = { "f", "F" }, - -- ["class"] = { "m", "M" }, - -- ["parameter"] = { "a", "A" }, - -- ["block"] = { "k", "K" }, - -- ["conditional"] = { "i", "I" }, - -- ["call"] = { "c", "C" }, - -- ["loop"] = { "l", "L" }, - -- ["statement"] = { "s", "S" }, - -- ["comment"] = { "/", "?" }, - -- }, - -- -- The below is for treesitter hint textobjects plugin - -- hint_labels = { "h", "j", "f", "d", "n", "v", "s", "l", "a" }, - -- }, end M.setup = function() - -- TODO: refacor this whole file and treesitter in general - -- if not package.loaded['nvim-treesitter'] then return end - -- - -- Custom parsers - -- local parser_config = require("nvim-treesitter.parsers").get_parser_configs() - -- parser_config.make = { - -- install_info = { - -- url = "https://github.com/alemuller/tree-sitter-make", -- local path or git repo - -- files = {"src/parser.c"}, - -- requires_generate_from_grammar = true - -- } - -- } - -- parser_config.just = { - -- install_info = { - -- url = "~/dev/tree-sitter-just", -- local path or git repo - -- files = {"src/parser.c"} - -- } - -- -- filetype = "just", -- if filetype does not agrees with parser name - -- -- used_by = {"bar", "baz"} -- additional filetypes that use this parser - -- } - -- Custom text objects - -- local textobj_prefixes = O.treesitter.textobj_prefixes - -- local textobj_suffixes = O.treesitter.textobj_suffixes - -- local textobj_sel_keymaps = {} - -- local textobj_swap_keymaps = {} - -- local textobj_move_keymaps = { - -- enable = O.plugin.ts_textobjects, - -- set_jumps = true, -- whether to set jumps in the jumplist - -- goto_next_start = {}, - -- goto_next_end = {}, - -- goto_previous_start = {}, - -- goto_previous_end = {}, - -- } - -- for obj, suffix in pairs(textobj_suffixes) do - -- if textobj_prefixes["goto_next"] ~= nil then - -- textobj_move_keymaps["goto_next_start"][textobj_prefixes["goto_next"] .. suffix[1]] = "@" .. obj .. ".outer" - -- textobj_move_keymaps["goto_next_end"][textobj_prefixes["goto_next"] .. suffix[2]] = "@" .. obj .. ".outer" - -- end - -- if textobj_prefixes["goto_previous"] ~= nil then - -- textobj_move_keymaps["goto_previous_start"][textobj_prefixes["goto_previous"] .. suffix[2]] = "@" .. obj .. ".outer" - -- textobj_move_keymaps["goto_previous_end"][textobj_prefixes["goto_previous"] .. suffix[1]] = "@" .. obj .. ".outer" - -- end - -- - -- if textobj_prefixes["inner"] ~= nil then - -- textobj_sel_keymaps[textobj_prefixes["inner"] .. suffix[1]] = "@" .. obj .. ".inner" - -- end - -- if textobj_prefixes["outer"] ~= nil then - -- textobj_sel_keymaps[textobj_prefixes["outer"] .. suffix[1]] = "@" .. obj .. ".outer" - -- end - -- - -- if textobj_prefixes["swap"] ~= nil then - -- textobj_swap_keymaps[textobj_prefixes["swap"] .. suffix[1]] = "@" .. obj .. ".outer" - -- end - -- end - -- vim.g.ts_hint_textobject_keys = O.treesitter.hint_labels -- Requires https://github.com/mfussenegger/nvim-ts-hint-textobject/pull/2 - -- - -- -- Add which key menu entries - -- local status, wk = pcall(require, "which-key") - -- if status then - -- local normal = { - -- mode = "n", -- Normal mode - -- } - -- local operators = { - -- mode = "o", -- Operator mode - -- } - -- wk.register(textobj_sel_keymaps, operators) - -- wk.register({ - -- ["m"] = "Hint Objects", - -- ["."] = "Textsubject", - -- [";"] = "Textsubject-big", - -- }, operators) - -- wk.register(textobj_swap_keymaps, normal) - -- wk.register({ - -- [textobj_prefixes["swap"]] = "Swap", - -- -- [textobj_prefixes["goto_next"]] = "Jump [", - -- -- [textobj_prefixes["goto_previous"]] = "Jump ]" - -- }, normal) - -- wk.register(textobj_move_keymaps["goto_next_start"], normal) - -- wk.register(textobj_move_keymaps["goto_next_end"], normal) - -- wk.register(textobj_move_keymaps["goto_previous_start"], normal) - -- wk.register(textobj_move_keymaps["goto_previous_end"], normal) - -- end - local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs") if not status_ok then return end - treesitter_configs.setup(O.treesitter) + treesitter_configs.setup(lvim.builtin.treesitter) end return M diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 47661df6..1126bea5 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - O.plugin.which_key = { + lvim.builtin.which_key = { active = false, setup = { plugins = { @@ -117,14 +117,15 @@ M.config = function() "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics", }, - f = { "silent FormatWrite", "Format" }, + -- f = { "silent FormatWrite", "Format" }, + f = { "lua vim.lsp.buf.formatting()", "Format" }, i = { "LspInfo", "Info" }, j = { - "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})", + "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})", "Next Diagnostic", }, k = { - "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})", + "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", "Prev Diagnostic", }, l = { "silent lua require('lint').try_lint()", "Lint" }, @@ -171,29 +172,18 @@ M.setup = function() return end - which_key.setup(O.plugin.which_key.setup) + which_key.setup(lvim.builtin.which_key.setup) - local opts = O.plugin.which_key.opts - local vopts = O.plugin.which_key.vopts + local opts = lvim.builtin.which_key.opts + local vopts = lvim.builtin.which_key.vopts - local mappings = O.plugin.which_key.mappings - local vmappings = O.plugin.which_key.vmappings - - -- if O.plugin.ts_playground.active then - -- vim.api.nvim_set_keymap("n", "Th", ":TSHighlightCapturesUnderCursor", { noremap = true, silent = true }) - -- mappings[""] = "Highlight Capture" - -- end - - if O.plugin.zen.active then - vim.api.nvim_set_keymap("n", "z", ":ZenMode", { noremap = true, silent = true }) - mappings["z"] = "Zen" - end + local mappings = lvim.builtin.which_key.mappings + local vmappings = lvim.builtin.which_key.vmappings local wk = require "which-key" wk.register(mappings, opts) wk.register(vmappings, vopts) - wk.register(O.user_which_key, opts) end return M diff --git a/lua/core/zen.lua b/lua/core/zen.lua deleted file mode 100644 index 99a5d769..00000000 --- a/lua/core/zen.lua +++ /dev/null @@ -1,34 +0,0 @@ -local M = {} -M.config = function() - O.plugin["zen"] = { - window = { - backdrop = 1, - height = 0.85, -- height of the Zen window - options = { - signcolumn = "no", -- disable signcolumn - number = false, -- disable number column - relativenumber = false, -- disable relative numbers - -- cursorline = false, -- disable cursorline - -- cursorcolumn = false, -- disable cursor column - -- foldcolumn = "0", -- disable fold column - -- list = false, -- disable whitespace characters - }, - }, - plugins = { - gitsigns = { enabled = false }, -- disables git signs - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, - } -end - -M.setup = function() - local status_ok, zen_mode = pcall(require, "zen-mode") - if not status_ok then - return - end - zen_mode.setup(O.plugin.zen) -end - -return M diff --git a/lua/default-config.lua b/lua/default-config.lua index aaba1829..0c36054c 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -4,61 +4,33 @@ CACHE_PATH = vim.fn.stdpath "cache" TERMINAL = vim.fn.expand "$TERMINAL" USER = vim.fn.expand "$USER" -O = { - keys = { - leader_key = "space", - }, +lvim = { + leader = "space", colorscheme = "spacegray", line_wrap_cursor_movement = true, transparent_window = false, format_on_save = true, - lint_on_save = true, vsnip_dir = os.getenv "HOME" .. "/.config/snippets", + database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 }, + keys = {}, - default_options = { - backup = false, -- creates a backup file - clipboard = "unnamedplus", -- allows neovim to access the system clipboard - cmdheight = 2, -- more space in the neovim command line for displaying messages - colorcolumn = "99999", -- fixes indentline for now - completeopt = { "menuone", "noselect" }, - conceallevel = 0, -- so that `` is visible in markdown files - fileencoding = "utf-8", -- the encoding written to a file - foldmethod = "manual", -- folding, set to "expr" for treesitter based foloding - foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding - guifont = "monospace:h17", -- the font used in graphical neovim applications - hidden = true, -- required to keep multiple buffers and open multiple buffers - hlsearch = true, -- highlight all matches on previous search pattern - ignorecase = true, -- ignore case in search patterns - mouse = "a", -- allow the mouse to be used in neovim - pumheight = 10, -- pop up menu height - showmode = false, -- we don't need to see things like -- INSERT -- anymore - showtabline = 2, -- always show tabs - smartcase = true, -- smart case - smartindent = true, -- make indenting smarter again - splitbelow = true, -- force all horizontal splits to go below current window - splitright = true, -- force all vertical splits to go to the right of current window - swapfile = false, -- creates a swapfile - termguicolors = true, -- set term gui colors (most terminals support this) - timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds) - title = true, -- set the title of window to the value of the titlestring - -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to - undodir = CACHE_PATH .. "/undo", -- set an undo directory - undofile = true, -- enable persisten undo - updatetime = 300, -- faster completion - writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited - expandtab = true, -- convert tabs to spaces - shiftwidth = 2, -- the number of spaces inserted for each indentation - tabstop = 2, -- insert 2 spaces for a tab - cursorline = true, -- highlight the current line - number = true, -- set numbered lines - relativenumber = false, -- set relative numbered lines - numberwidth = 4, -- set number column width to 2 {default 4} - signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time - wrap = false, -- display lines as one long line - spell = false, - spelllang = "en", - scrolloff = 8, -- is one of my fav - sidescrolloff = 8, + -- TODO why do we need this? + builtin = { + lspinstall = {}, + telescope = {}, + compe = {}, + autopairs = {}, + treesitter = {}, + nvimtree = {}, + gitsigns = {}, + which_key = {}, + comment = {}, + rooter = {}, + galaxyline = {}, + bufferline = {}, + dap = {}, + dashboard = {}, + terminal = {}, }, lsp = { @@ -76,144 +48,699 @@ O = { on_attach_callback = nil, }, - disabled_built_ins = { - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "gzip", - "zip", - "zipPlugin", - "tar", - "tarPlugin", -- 'man', - "getscript", - "getscriptPlugin", - "vimball", - "vimballPlugin", - "2html_plugin", - "logipat", - "rrhelper", - "spellfile_plugin", - -- 'matchit', 'matchparen', 'shada_plugin', - }, - - plugin = { - lspinstall = {}, - telescope = {}, - compe = {}, - autopairs = {}, - treesitter = {}, - formatter = {}, - lint = {}, - nvimtree = {}, - gitsigns = {}, - which_key = {}, - comment = {}, - rooter = {}, - galaxyline = {}, - bufferline = {}, - dap = {}, - dashboard = {}, - terminal = {}, - zen = {}, - }, - - -- TODO: refactor for tree - auto_close_tree = 0, - nvim_tree_disable_netrw = 0, - - database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 }, - - -- TODO: just using mappings (leader mappings) - user_which_key = {}, - - user_plugins = { + plugins = { -- use lv-config.lua for this not put here }, - user_autocommands = { + autocommands = { { "FileType", "qf", "set nobuflisted" }, }, +} - formatters = { - filetype = {}, - }, +local schemas = nil +local common_on_attach = require("lsp").common_on_attach +local common_capabilities = require("lsp").common_capabilities() +local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") +if status_ok then + schemas = jsonls_settings.get_default_schemas() +end - -- TODO move all of this into lang specific files, only require when using - lang = { - efm = {}, - emmet = { active = false }, - svelte = {}, - tailwindcss = { - active = false, - filetypes = { - "html", - "css", - "scss", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", +-- TODO move all of this into lang specific files, only require when using +lvim.lang = { + c = { + formatter = { + exe = "clang_format", + args = {}, + stdin = true, + }, + linters = { + "clangtidy", + }, + lsp = { + provider = "clangd", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", + "--background-index", + "--header-insertion=never", + "--cross-file-rename", + "--clang-tidy", + "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, }, }, - tsserver = { - -- @usage can be 'eslint' or 'eslint_d' - linter = "", - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, + }, + cpp = { + formatter = { + exe = "clang_format", + args = {}, + stdin = true, + }, + linters = { + "cppcheck", + "clangtidy", + }, + lsp = { + provider = "clangd", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", + "--background-index", + "--header-insertion=never", + "--cross-file-rename", + "--clang-tidy", + "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, }, - formatter = { - exe = "prettier", - args = {}, + }, + }, + csharp = { + lsp = { + provider = "omnisharp", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/csharp/omnisharp/run", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + cmake = { + formatter = { + exe = "clang-format", + args = {}, + }, + lsp = { + provider = "cmake", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + clojure = { + lsp = { + provider = "clojure_lsp", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/clojure/clojure-lsp", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + css = { + formatter = { + exe = "prettier", + args = {}, + }, + lsp = { + provider = "cssls", + setup = { + cmd = { + "node", + DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + dart = { + lsp = { + provider = "dartls", + setup = { + cmd = { + "dart", + "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot", + "--lsp", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + formatter = { + exe = "dart", + args = { "format" }, + stdin = true, + }, + }, + docker = { + lsp = { + provider = "dockerls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + elixir = { + formatter = { + exe = "mix", + args = { "format" }, + stdin = true, + }, + lsp = { + provider = "elixirls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + elm = { + lsp = { + provider = "elmls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server", + }, + on_attach = common_on_attach, + init_options = { + elmAnalyseTrigger = "change", + elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", + elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", + elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", + }, + }, + }, + }, + erlang = { + lsp = { + provider = "erlangls", + setup = { + cmd = { + "erlang_ls", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + emmet = { active = false }, + go = { + formatter = { + exe = "gofmt", + args = {}, + stdin = true, + }, + linters = { + "golangcilint", + "revive", + }, + lsp = { + provider = "gopls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/go/gopls", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + graphql = { + lsp = { + provider = "graphql", + setup = { + cmd = { + "graphql-lsp", + "server", + "-m", + "stream", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + html = { + linters = { + "tidy", + -- https://docs.errata.ai/vale/scoping#html + "vale", + }, + lsp = { + provider = "html", + setup = { + cmd = { + "node", + DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + java = { + formatter = { + exe = "prettier", + args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, + }, + lsp = { + provider = "jdtls", + setup = { + cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + json = { + formatter = { + exe = "python", + args = { "-m", "json.tool" }, + stdin = true, + }, + lsp = { + provider = "jsonls", + setup = { + cmd = { + "node", + DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + settings = { + json = { + schemas = schemas, + -- = { + -- { + -- fileMatch = { "package.json" }, + -- url = "https://json.schemastore.org/package.json", + -- }, + -- }, + }, + }, + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) + end, + }, + }, + }, + }, + }, + julia = { + lsp = { + provider = "julials", + setup = { + { + "julia", + "--startup-file=no", + "--history-file=no", + -- vim.fn.expand "~/.config/nvim/lua/lsp/julia/run.jl", + CONFIG_PATH .. "/utils/julia/run.jl", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + kotlin = { + lsp = { + provider = "kotlin_language_server", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server", + }, + on_attach = common_on_attach, + root_dir = function(fname) + local util = require "lspconfig/util" + + local root_files = { + "settings.gradle", -- Gradle (multi-project) + "settings.gradle.kts", -- Gradle (multi-project) + "build.xml", -- Ant + "pom.xml", -- Maven + } + + local fallback_root_files = { + "build.gradle", -- Gradle + "build.gradle.kts", -- Gradle + } + return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname) + end, + }, + }, + }, + lua = { + formatter = { + exe = "stylua", + args = {}, + }, + linters = { "luacheck" }, + lsp = { + provider = "sumneko_lua", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/lua/sumneko-lua-language-server", + "-E", + DATA_PATH .. "/lspinstall/lua/main.lua", + }, + on_attach = common_on_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + -- Setup your lua path + path = vim.split(package.path, ";"), + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim", "O" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = { + [vim.fn.expand "~/.local/share/lunarvim/lvim/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + }, + maxPreload = 100000, + preloadFileSize = 1000, + }, + }, + }, + }, + }, + }, + php = { + formatter = { + exe = "phpcbf", + args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) }, + }, + linters = {}, + lsp = { + provider = "intelephense", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", + "--stdio", + }, + on_attach = common_on_attach, + filetypes = { "php", "phtml" }, + settings = { + intelephense = { + environment = { + phpVersion = "7.4", + }, + }, + }, + }, + }, + }, + javascript = { + -- @usage can be prettier or eslint + formatter = { + exe = "prettier", + args = {}, + }, + linters = { + "eslint", + }, + lsp = { + provider = "tsserver", + setup = { + cmd = { + -- TODO: + DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", + "--stdio", + }, + on_attach = require("lsp").common_on_attach, + capabilities = require("lsp").common_capabilities(), + }, + }, + }, + python = { + -- @usage can be flake8 or yapf + formatter = { + exe = "black", + args = {}, + }, + linters = { + "flake8", + "pylint", + "mypy", + }, + lsp = { + provider = "pyright", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")' + -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")' + r = { + formatter = { + exe = "R", + args = { + "--slave", + "--no-restore", + "--no-save", + '-e "formatR::tidy_source(text=readr::read_file(file(\\"stdin\\")), arrow=FALSE)"', + }, + stdin = true, + }, + lsp = { + provider = "r_language_server", + setup = { + cmd = { + "R", + "--slave", + "-e", + "languageserver::run()", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + ruby = { + formatter = { + exe = "rufo", + args = { "-x" }, + stdin = true, + }, + linters = { "ruby" }, + lsp = { + provider = "solargraph", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", + "stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + rust = { + formatter = { + exe = "rustfmt", + args = { "--emit=stdout", "--edition=2018" }, + stdin = true, + }, + lsp = { + provider = "rust_analyzer", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/rust/rust-analyzer", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + sh = { + -- @usage can be 'shfmt' + formatter = { + exe = "shfmt", + args = {}, + }, + -- @usage can be 'shellcheck' + linters = { "shellcheck" }, + lsp = { + provider = "bashls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", + "start", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + svelte = { + lsp = { + provider = "svelte", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + swift = { + formatter = { + exe = "swiftformat", + args = {}, + stdin = true, + }, + lsp = { + provider = "sourcekit", + setup = { + cmd = { + "xcrun", + "sourcekit-lsp", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + tailwindcss = { + active = false, + filetypes = { + "html", + "css", + "scss", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + }, + }, + terraform = { + formatter = { + exe = "terraform", + args = { "fmt" }, + stdin = false, + }, + lsp = { + provider = "terraformls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/terraform/terraform-ls", + "serve", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + vim = { + linters = { "vint" }, + lsp = { + provider = "vimls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + vue = { + formatter = { + exe = "prettier", + args = { + "--stdin-filepath", + "${FILEPATH}", + }, + stdin = true, + }, + lsp = { + provider = "vetur", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + yaml = { + formatter = { + exe = "prettier", + args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, + stdin = true, + }, + lsp = { + provider = "yamlls", + setup = { + cmd = { + DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", + "--stdio", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, + zig = { + formatter = { + exe = "zig", + args = { "fmt" }, + stdin = false, + }, + lsp = { + provider = "zls", + setup = { + cmd = { + "zls", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, }, }, }, } +require("core.which-key").config() require "core.status_colors" require("core.gitsigns").config() require("core.compe").config() require("core.dashboard").config() require("core.dap").config() require("core.terminal").config() -require("core.zen").config() require("core.telescope").config() require("core.treesitter").config() -require("core.which-key").config() require("core.nvimtree").config() - -require("lang.clang").config() -require("lang.clojure").config() -require("lang.cmake").config() -require("lang.cs").config() -require("lang.css").config() -require("lang.dart").config() -require("lang.dockerfile").config() -require("lang.elixir").config() -require("lang.elm").config() -require("lang.go").config() -require("lang.graphql").config() -require("lang.html").config() -require("lang.java").config() -require("lang.json").config() -require("lang.julia").config() -require("lang.kotlin").config() -require("lang.lua").config() -require("lang.php").config() -require("lang.python").config() -require("lang.r").config() -require("lang.ruby").config() -require("lang.rust").config() -require("lang.sh").config() -require("lang.scala").config() -require("lang.svelte").config() -require("lang.swift").config() -require("lang.terraform").config() -require("lang.tex").config() -require("lang.vim").config() -require("lang.vue").config() -require("lang.yaml").config() -require("lang.zig").config() -require("lang.zsh").config() diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 5ee54890..5e09dc7d 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -89,17 +89,17 @@ if vim.fn.has "mac" == 1 then default_keys.normal_mode[8][1] = "" end -if O.keys.leader_key == " " or O.keys.leader_key == "space" then +if lvim.leader == " " or lvim.leader == "space" then vim.g.mapleader = " " else - vim.g.mapleader = O.keys.leader_key + vim.g.mapleader = lvim.leader end local function get_user_keys(mode) - if O.keys[mode] == nil then + if lvim.keys[mode] == nil then return default_keys[mode] else - return O.keys[mode] + return lvim.keys[mode] end end diff --git a/lua/lang/clang.lua b/lua/lang/clang.lua deleted file mode 100644 index 0a568620..00000000 --- a/lua/lang/clang.lua +++ /dev/null @@ -1,159 +0,0 @@ -local M = {} - -M.config = function() - O.lang.clang = { - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - cross_file_rename = true, - header_insertion = "never", - filetypes = { "c", "cpp", "objc" }, - formatter = { - exe = "clang-format", - args = {}, - stdin = true, - }, - linters = { - "cppcheck", - "clangtidy", - }, - debug = { - adapter = { - command = "/usr/bin/lldb-vscode", - }, - stop_on_entry = false, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", - }, - } -end - -M.format = function() - local shared_config = { - function() - return { - exe = O.lang.clang.formatter.exe, - args = O.lang.clang.formatter.args, - stdin = O.lang.clang.formatter.stdin, - cwd = vim.fn.expand "%:h:p", - } - end, - } - O.formatters.filetype["c"] = shared_config - O.formatters.filetype["cpp"] = shared_config - O.formatters.filetype["objc"] = shared_config - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - c = O.lang.clang.linters, - cpp = O.lang.clang.linters, - } -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "clangd" then - return - end - local clangd_flags = { "--background-index" } - - if O.lang.clang.cross_file_rename then - table.insert(clangd_flags, "--cross-file-rename") - end - - table.insert(clangd_flags, "--header-insertion=" .. O.lang.clang.header_insertion) - - require("lspconfig").clangd.setup { - cmd = { O.lang.clang.lsp.path, unpack(clangd_flags) }, - on_attach = require("lsp").common_on_attach, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.clang.diagnostics.virtual_text, - signs = O.lang.clang.diagnostics.signs, - underline = O.lang.clang.diagnostics.underline, - update_in_insert = true, - }), - }, - } -end - -M.dap = function() - if O.plugin.dap.active then - local dap_install = require "dap-install" - local dap = require "dap" - dap_install.config("ccppr_vsc_dbg", {}) - dap.adapters.lldb = { - type = "executable", - command = O.lang.clang.debug.adapter.command, - name = "lldb", - } - local shared_dap_config = { - { - name = "Launch", - type = "lldb", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = O.lang.clang.debug.stop_on_entry, - args = {}, - env = function() - local variables = {} - for k, v in pairs(vim.fn.environ()) do - table.insert(variables, string.format("%s=%s", k, v)) - end - return variables - end, - runInTerminal = false, - }, - { - -- If you get an "Operation not permitted" error using this, try disabling YAMA: - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - name = "Attach to process", - type = "lldb", -- Adjust this to match your adapter name (`dap.adapters.`) - request = "attach", - pid = function() - local output = vim.fn.system { "ps", "a" } - local lines = vim.split(output, "\n") - local procs = {} - for _, line in pairs(lines) do - -- output format - -- " 107021 pts/4 Ss 0:00 /bin/zsh " - local parts = vim.fn.split(vim.fn.trim(line), " \\+") - local pid = parts[1] - local name = table.concat({ unpack(parts, 5) }, " ") - if pid and pid ~= "PID" then - pid = tonumber(pid) - if pid ~= vim.fn.getpid() then - table.insert(procs, { pid = tonumber(pid), name = name }) - end - end - end - local choices = { "Select process" } - for i, proc in ipairs(procs) do - table.insert(choices, string.format("%d: pid=%d name=%s", i, proc.pid, proc.name)) - end - local choice = vim.fn.inputlist(choices) - if choice < 1 or choice > #procs then - return nil - end - return procs[choice].pid - end, - args = {}, - }, - } - dap.configurations.c = shared_dap_config - dap.configurations.cpp = shared_dap_config - end -end - -return M diff --git a/lua/lang/clojure.lua b/lua/lang/clojure.lua deleted file mode 100644 index e973a0e3..00000000 --- a/lua/lang/clojure.lua +++ /dev/null @@ -1,37 +0,0 @@ -local M = {} - -M.config = function() - O.lang.erlang = { - lsp = { - path = DATA_PATH .. "/lspinstall/clojure/clojure-lsp", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "clojure_lsp" then - return - end - - require("lspconfig").clojure_lsp.setup { - cmd = { O.lang.erlang.lsp.path }, - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/cmake.lua b/lua/lang/cmake.lua deleted file mode 100644 index a4d8d045..00000000 --- a/lua/lang/cmake.lua +++ /dev/null @@ -1,42 +0,0 @@ -local M = {} - -M.config = function() - O.lang.cmake = { - formatter = { - exe = "clang-format", - args = {}, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server", - }, - } -end - -M.format = function() - -- TODO: implement formatters (if applicable) - return "No formatters configured!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "cmake" then - return - end - - require("lspconfig").cmake.setup { - cmd = { O.lang.cmake.lsp.path }, - on_attach = require("lsp").common_on_attach, - filetypes = { "cmake" }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/cs.lua b/lua/lang/cs.lua deleted file mode 100644 index 851e226f..00000000 --- a/lua/lang/cs.lua +++ /dev/null @@ -1,38 +0,0 @@ -local M = {} - -M.config = function() - O.lang.csharp = { - lsp = { - path = DATA_PATH .. "/lspinstall/csharp/omnisharp/run", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "omnisharp" then - return - end - - -- C# language server (csharp/OmniSharp) setup - require("lspconfig").omnisharp.setup { - on_attach = require("lsp").common_on_attach, - cmd = { O.lang.csharp.lsp.path, "--languageserver", "--hostPID", tostring(vim.fn.getpid()) }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/css.lua b/lua/lang/css.lua deleted file mode 100644 index 257896f2..00000000 --- a/lua/lang/css.lua +++ /dev/null @@ -1,77 +0,0 @@ -local M = {} - -M.config = function() - O.lang.css = { - virtual_text = true, - formatter = { - exe = "prettier", - args = {}, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", - }, - } -end - -M.format = function() - vim.cmd "let proj = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "proj" - - -- use the global prettier if you didn't find the local one - local prettier_instance = root_dir .. "/node_modules/.bin/prettier" - if vim.fn.executable(prettier_instance) ~= 1 then - prettier_instance = O.lang.tsserver.formatter.exe - end - - local ft = vim.bo.filetype - O.formatters.filetype[ft] = { - function() - local args = { "--stdin-filepath", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) } - -- TODO: O.lang.[ft].formatter.args - local extend_args = O.lang.css.formatter.args - - for i = 1, #extend_args do - table.insert(args, extend_args[i]) - end - - return { - exe = prettier_instance, - args = args, - stdin = true, - } - end, - } - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "cssls" then - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - -- npm install -g vscode-css-languageserver-bin - require("lspconfig").cssls.setup { - cmd = { - "node", - O.lang.css.lsp.path, - "--stdio", - }, - on_attach = require("lsp").common_on_attach, - capabilities = capabilities, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/dart.lua b/lua/lang/dart.lua deleted file mode 100644 index b95d303d..00000000 --- a/lua/lang/dart.lua +++ /dev/null @@ -1,59 +0,0 @@ -local M = {} - -M.config = function() - O.lang.dart = { - sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot", - formatter = { - exe = "dart", - args = { "format" }, - stdin = true, - }, - } -end - -M.format = function() - O.formatters.filetype["dart"] = { - function() - return { - exe = O.lang.dart.formatter.exe, - args = O.lang.dart.formatter.args, - stdin = O.lang.dart.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "dartls" then - return - end - - require("lspconfig").dartls.setup { - cmd = { "dart", O.lang.dart.sdk_path, "--lsp" }, - on_attach = require("lsp").common_on_attach, - init_options = { - closingLabels = false, - flutterOutline = false, - onlyAnalyzeProjectsWithOpenFiles = false, - outline = false, - suggestFromUnimportedLibraries = true, - }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/dockerfile.lua b/lua/lang/dockerfile.lua deleted file mode 100644 index 35134f36..00000000 --- a/lua/lang/dockerfile.lua +++ /dev/null @@ -1,39 +0,0 @@ -local M = {} - -M.config = function() - O.lang.docker = { - lsp = { - path = DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "dockerls" then - return - end - - -- npm install -g dockerfile-language-server-nodejs - require("lspconfig").dockerls.setup { - cmd = { O.lang.docker.lsp.path, "--stdio" }, - on_attach = require("lsp").common_on_attach, - root_dir = vim.loop.cwd, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/elixir.lua b/lua/lang/elixir.lua deleted file mode 100644 index e702e89b..00000000 --- a/lua/lang/elixir.lua +++ /dev/null @@ -1,61 +0,0 @@ -local M = {} - -M.config = function() - O.lang.elixir = { - formatter = { - exe = "mix", - args = { "format" }, - stdin = true, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh", - }, - } -end - -M.format = function() - O.formatters.filetype["elixir"] = { - function() - return { - exe = O.lang.elixir.formatter.exe, - args = O.lang.elixir.formatter.args, - stdin = O.lang.elixir.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "elixirls" then - return - end - - require("lspconfig").elixirls.setup { - cmd = { O.lang.elixir.lsp.path }, - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - --- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) --- vim.cmd [[ --- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir --- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir --- au BufRead,BufNewFile mix.lock set filetype=elixir --- ]] - -return M diff --git a/lua/lang/elm.lua b/lua/lang/elm.lua deleted file mode 100644 index 8fc8cebb..00000000 --- a/lua/lang/elm.lua +++ /dev/null @@ -1,48 +0,0 @@ -local M = {} - -M.config = function() - local elm_bin = DATA_PATH .. "/lspinstall/elm/node_modules/.bin" - - O.lang.elm = { - lsp = { - path = elm_bin .. "/elm-language-server", - format = elm_bin .. "/elm-format", - root = elm_bin, - test = elm_bin .. "/elm-test", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "elmls" then - return - end - - require("lspconfig").elmls.setup { - cmd = { O.lang.elm.lsp.path }, - on_attach = require("lsp").common_on_attach, - init_options = { - elmAnalyseTrigger = "change", - elmFormatPath = O.lang.elm.lsp.format, - elmPath = O.lang.elm.lsp.root, - elmTestPath = O.lang.elm.lsp.test, - }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/erlang.lua b/lua/lang/erlang.lua deleted file mode 100644 index c98b65cf..00000000 --- a/lua/lang/erlang.lua +++ /dev/null @@ -1,32 +0,0 @@ -local M = {} - -M.config = function() - O.lang.erlang = {} -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "erlangls" then - return - end - - require("lspconfig").erlangls.setup { - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/euphoria3.lua b/lua/lang/euphoria3.lua deleted file mode 100644 index f8e32c61..00000000 --- a/lua/lang/euphoria3.lua +++ /dev/null @@ -1,42 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "elixirls" then - return - end - - -- TODO: Remove this at some point - require("lspconfig").elixirls.setup { - cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh" }, - on_attach = require("lsp").common_on_attach, - } -end - --- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) --- vim.cmd([[ --- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir --- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir --- au BufRead,BufNewFile mix.lock set filetype=elixir --- ]]) - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/fish.lua b/lua/lang/fish.lua deleted file mode 100644 index a347cff7..00000000 --- a/lua/lang/fish.lua +++ /dev/null @@ -1,28 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatters (if applicable) - return "No formatters configured!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - -- TODO: implement lsp - return "No LSP configured!" -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/go.lua b/lua/lang/go.lua deleted file mode 100644 index 16b55ffb..00000000 --- a/lua/lang/go.lua +++ /dev/null @@ -1,60 +0,0 @@ -local M = {} - -M.config = function() - O.lang.go = { - formatter = { - exe = "gofmt", - args = {}, - stdin = true, - }, - linters = { - "golangcilint", - "revive", - }, - lsp = { - path = DATA_PATH .. "/lspinstall/go/gopls", - }, - } -end - -M.format = function() - O.formatters.filetype["go"] = { - function() - return { - exe = O.lang.go.formatter.exe, - args = O.lang.go.formatter.args, - stdin = O.lang.go.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - go = O.lang.go.linters, - } -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "gopls" then - require("lspconfig").gopls.setup { - cmd = { O.lang.go.lsp.path }, - settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } }, - root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"), - init_options = { usePlaceholders = true, completeUnimported = true }, - on_attach = require("lsp").common_on_attach, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/graphql.lua b/lua/lang/graphql.lua deleted file mode 100644 index 601541a6..00000000 --- a/lua/lang/graphql.lua +++ /dev/null @@ -1,38 +0,0 @@ -local M = {} - -M.config = function() - O.lang.graphql = { - lsp = { - path = "graphql-lsp", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "graphql" then - return - end - - -- npm install -g graphql-language-service-cli - require("lspconfig").graphql.setup { - cmd = { O.lang.graphql.lsp.path, "server", "-m", "stream" }, - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/html.lua b/lua/lang/html.lua deleted file mode 100644 index b14f6e1a..00000000 --- a/lua/lang/html.lua +++ /dev/null @@ -1,50 +0,0 @@ -local M = {} - -M.config = function() - O.lang.html = { - linters = { - "tidy", - -- https://docs.errata.ai/vale/scoping#html - "vale", - }, - lsp = { - path = DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", - }, - } -end - -M.format = function() - -- TODO: implement formatters (if applicable) - return "No formatters configured!" -end - -M.lint = function() - require("lint").linters_by_ft = { - html = O.lang.html.linters, - } -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "html" then - -- npm install -g vscode-html-languageserver-bin - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - - require("lspconfig").html.setup { - cmd = { - "node", - O.lang.html.lsp.path, - "--stdio", - }, - on_attach = require("lsp").common_on_attach, - capabilities = capabilities, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/java.lua b/lua/lang/java.lua deleted file mode 100644 index d84c0000..00000000 --- a/lua/lang/java.lua +++ /dev/null @@ -1,127 +0,0 @@ -local M = {} - -M.config = function() - O.lang.java = { - java_tools = { - active = false, - }, - formatter = { - exe = "prettier", - args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, - }, - } -end - -M.format = function() - vim.cmd "let proj = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "proj" - - -- use the global prettier if you didn't find the local one - local prettier_instance = root_dir .. "/node_modules/.bin/prettier" - if vim.fn.executable(prettier_instance) ~= 1 then - prettier_instance = O.lang.tsserver.formatter.exe - end - - O.formatters.filetype["java"] = { - function() - return { - exe = prettier_instance, - -- TODO: allow user to override this - args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, - stdin = true, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "jdtls" then - return - end - - if O.lang.java.java_tools.active then - -- find_root looks for parent directories relative to the current buffer containing one of the given arguments. - if vim.fn.has "mac" == 1 then - WORKSPACE_PATH = "/Users/" .. USER .. "/workspace/" - elseif vim.fn.has "unix" == 1 then - WORKSPACE_PATH = "/home/" .. USER .. "/workspace/" - else - print "Unsupported system" - end - - JAVA_LS_EXECUTABLE = os.getenv "HOME" .. "/.local/share/lunarvim/lvim/utils/bin/jdtls" - - require("jdtls").start_or_attach { - on_attach = require("lsp").common_on_attach, - cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") }, - } - - vim.api.nvim_set_keymap( - "n", - "la", - ":lua require('jdtls').code_action()", - { noremap = true, silent = true } - ) - vim.api.nvim_set_keymap( - "n", - "lR", - ":lua require('jdtls').code_action(false, 'refactor')", - { noremap = true, silent = true } - ) - - vim.cmd "command! -buffer JdtCompile lua require('jdtls').compile()" - vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" - -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" - vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" - -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" - else - local util = require "lspconfig/util" - - require("lspconfig").jdtls.setup { - on_attach = require("lsp").common_on_attach, - cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, - filetypes = { "java" }, - root_dir = util.root_pattern { ".git", "build.gradle", "pom.xml" }, - -- init_options = {bundles = bundles} - -- on_attach = require'lsp'.common_on_attach - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - --- local bundles = { --- vim.fn.glob( --- CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar") --- }; - --- require('jdtls').start_or_attach({ --- on_attach = on_attach, --- cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"}, --- root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}), --- init_options = {bundles = bundles} --- }) - --- TODO: setup autoformat stuff later --- _java = { --- -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, --- { --- 'FileType', 'java', --- 'nnoremap ca lua require(\'jdtls\').code_action()' --- } --- } - -return M diff --git a/lua/lang/javascript.lua b/lua/lang/javascript.lua deleted file mode 100644 index 178c6f54..00000000 --- a/lua/lang/javascript.lua +++ /dev/null @@ -1,25 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/javascriptreact.lua b/lua/lang/javascriptreact.lua deleted file mode 100644 index 178c6f54..00000000 --- a/lua/lang/javascriptreact.lua +++ /dev/null @@ -1,25 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/json.lua b/lua/lang/json.lua deleted file mode 100644 index e46f38cb..00000000 --- a/lua/lang/json.lua +++ /dev/null @@ -1,72 +0,0 @@ -local M = {} - -M.config = function() - O.lang.json = { - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - formatter = { - exe = "python", - args = { "-m", "json.tool" }, - stdin = true, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", - }, - } -end - -M.format = function() - O.formatters.filetype["json"] = { - function() - return { - exe = O.lang.json.formatter.exe, - args = O.lang.json.formatter.args, - stdin = O.lang.json.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "jsonls" then - return - end - - -- npm install -g vscode-json-languageserver - require("lspconfig").jsonls.setup { - cmd = { - "node", - O.lang.json.lsp.path, - "--stdio", - }, - on_attach = require("lsp").common_on_attach, - - commands = { - Format = { - function() - vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) - end, - }, - }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/julia.lua b/lua/lang/julia.lua deleted file mode 100644 index a1c0241d..00000000 --- a/lua/lang/julia.lua +++ /dev/null @@ -1,53 +0,0 @@ -local M = {} - -M.config = function() - O.lang.julia = { - lsp = { - path = CONFIG_PATH .. "/lua/lsp/julia/run.jl", - }, - } -end - -M.format = function() - -- todo: implement formatters (if applicable) - return "no formatters configured!" -end - -M.lint = function() - -- todo: implement linters (if applicable) - return "no linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "julials" then - return - end - -- Add the following lines to a new julia file, e.g. install.jl - -- using Pkg - -- Pkg.instantiate() - -- Run the file you created. - -- julia install.jl - -- Julia language server will now be installed on your system. - - local cmd = { - "julia", - "--startup-file=no", - "--history-file=no", - -- vim.fn.expand "~/.config/nvim/lua/lsp/julia/run.jl", - O.lang.julia.lsp.path, - } - require("lspconfig").julials.setup { - cmd = cmd, - on_new_config = function(new_config, _) - new_config.cmd = cmd - end, - filetypes = { "julia" }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/kotlin.lua b/lua/lang/kotlin.lua deleted file mode 100644 index 3979424f..00000000 --- a/lua/lang/kotlin.lua +++ /dev/null @@ -1,67 +0,0 @@ -local M = {} - -M.config = function() - O.lang.kotlin = { - lsp = { - path = DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "kotlin_language_server" then - return - end - - --- default config for gradle-projects of the - --- kotlin-language-server: https://github.com/fwcd/kotlin-language-server - --- - --- This server requires vim to be aware of the kotlin-filetype. - --- You could refer for this capability to: - --- https://github.com/udalov/kotlin-vim (recommended) - --- Note that there is no LICENSE specified yet. - - local util = require "lspconfig/util" - - local bin_name = O.lang.kotlin.lsp.path - if vim.fn.has "win32" == 1 then - bin_name = bin_name .. ".bat" - end - - local root_files = { - "settings.gradle", -- Gradle (multi-project) - "settings.gradle.kts", -- Gradle (multi-project) - "build.xml", -- Ant - "pom.xml", -- Maven - } - - local fallback_root_files = { - "build.gradle", -- Gradle - "build.gradle.kts", -- Gradle - } - - require("lspconfig").kotlin_language_server.setup { - cmd = { bin_name }, - on_attach = require("lsp").common_on_attach, - root_dir = function(fname) - return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname) - end, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/less.lua b/lua/lang/less.lua deleted file mode 100644 index 178c6f54..00000000 --- a/lua/lang/less.lua +++ /dev/null @@ -1,25 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/lua.lua b/lua/lang/lua.lua deleted file mode 100644 index 6b981479..00000000 --- a/lua/lang/lua.lua +++ /dev/null @@ -1,87 +0,0 @@ -local M = {} - -M.config = function() - O.lang.lua = { - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - formatter = { - exe = "stylua", - args = {}, - stdin = false, - }, - linters = { "luacheck" }, - lsp = { - path = DATA_PATH .. "/lspinstall/lua/sumneko-lua-language-server", - }, - } -end - -M.format = function() - O.formatters.filetype["lua"] = { - function() - return { - exe = O.lang.lua.formatter.exe, - args = O.lang.lua.formatter.args, - stdin = O.lang.lua.formatter.stdin, - tempfile_prefix = ".formatter", - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - lua = O.lang.lua.linters, - } -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "sumneko_lua" then - -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) - local sumneko_main = string.gsub(O.lang.lua.lsp.path, "sumneko-lua-language-server", "main.lua") - - require("lspconfig").sumneko_lua.setup { - cmd = { O.lang.lua.lsp.path, "-E", sumneko_main }, - on_attach = require("lsp").common_on_attach, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - -- Setup your lua path - path = vim.split(package.path, ";"), - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim", "O" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = { - [vim.fn.expand "~/.local/share/lunarvim/lvim/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, - }, - maxPreload = 100000, - preloadFileSize = 1000, - }, - }, - }, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/php.lua b/lua/lang/php.lua deleted file mode 100644 index 632c4052..00000000 --- a/lua/lang/php.lua +++ /dev/null @@ -1,88 +0,0 @@ -local M = {} - -M.config = function() - O.lang.php = { - format = { - format = { - default = "psr12", - }, - }, - environment = { - php_version = "7.4", - }, - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - filetypes = { "php", "phtml" }, - formatter = { - exe = "phpcbf", - args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) }, - stdin = false, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", - }, - } -end - -M.format = function() - O.formatters.filetype["php"] = { - function() - return { - exe = O.lang.php.formatter.exe, - args = O.lang.php.formatter.args, - stdin = O.lang.php.formatter.stdin, - tempfile_prefix = ".formatter", - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "intelephense" then - return - end - - require("lspconfig").intelephense.setup { - cmd = { O.lang.php.lsp.path, "--stdio" }, - on_attach = require("lsp").common_on_attach, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.php.diagnostics.virtual_text, - signs = O.lang.php.diagnostics.signs, - underline = O.lang.php.diagnostics.underline, - update_in_insert = true, - }), - }, - filetypes = O.lang.php.filetypes, - settings = { - intelephense = { - format = { - braces = O.lang.php.format.braces, - }, - environment = { - phpVersion = O.lang.php.environment.php_version, - }, - }, - }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/python.lua b/lua/lang/python.lua deleted file mode 100644 index b51ea1c4..00000000 --- a/lua/lang/python.lua +++ /dev/null @@ -1,95 +0,0 @@ -local M = {} - -M.config = function() - O.lang.python = { - -- @usage can be flake8 or yapf - linter = "", - isort = false, - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - analysis = { - type_checking = "basic", - auto_search_paths = true, - use_library_code_types = true, - }, - formatter = { - exe = "yapf", - args = {}, - stdin = true, - }, - linters = { - "flake8", - "pylint", - "mypy", - }, - lsp = { - path = DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", - }, - } -end - -M.format = function() - O.formatters.filetype["python"] = { - function() - return { - exe = O.lang.python.formatter.exe, - args = O.lang.python.formatter.args, - stdin = O.lang.python.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - python = O.lang.python.linters, - } -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "pyright" then - return - end - -- npm i -g pyright - require("lspconfig").pyright.setup { - cmd = { - O.lang.python.lsp.path, - "--stdio", - }, - on_attach = require("lsp").common_on_attach, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.python.diagnostics.virtual_text, - signs = O.lang.python.diagnostics.signs, - underline = O.lang.python.diagnostics.underline, - update_in_insert = true, - }), - }, - settings = { - python = { - analysis = { - typeCheckingMode = O.lang.python.analysis.type_checking, - autoSearchPaths = O.lang.python.analysis.auto_search_paths, - useLibraryCodeForTypes = O.lang.python.analysis.use_library_code_types, - }, - }, - }, - } -end - -M.dap = function() - if O.plugin.dap.active then - local dap_install = require "dap-install" - dap_install.config("python_dbg", {}) - end -end - -return M diff --git a/lua/lang/r.lua b/lua/lang/r.lua deleted file mode 100644 index b05e6ee6..00000000 --- a/lua/lang/r.lua +++ /dev/null @@ -1,56 +0,0 @@ -local M = {} - -M.config = function() - -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")' - -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")' - O.lang.r = { - formatter = { - exe = "R", - args = { - "--slave", - "--no-restore", - "--no-save", - '-e "formatR::tidy_source(text=readr::read_file(file(\\"stdin\\")), arrow=FALSE)"', - }, - stdin = true, - }, - } -end - -M.format = function() - O.formatters.filetype["r"] = { - function() - return { - exe = O.lang.r.formatter.exe, - args = O.lang.r.formatter.args, - stdin = O.lang.r.formatter.stdin, - } - end, - } - O.formatters.filetype["rmd"] = O.formatters.filetype["r"] - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "r_language_server" then - return - end - -- R -e 'install.packages("languageserver",repos = "http://cran.us.r-project.org")' - require("lspconfig").r_language_server.setup {} -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/ruby.lua b/lua/lang/ruby.lua deleted file mode 100644 index 1975acfd..00000000 --- a/lua/lang/ruby.lua +++ /dev/null @@ -1,77 +0,0 @@ -local M = {} - -M.config = function() - O.lang.ruby = { - diagnostics = { - virtualtext = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - filetypes = { "rb", "erb", "rakefile", "ruby" }, - formatter = { - exe = "rufo", - args = { "-x" }, - stdin = true, - }, - linters = { "ruby" }, - lsp = { - path = DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", - }, - } -end - -M.format = function() - O.formatters.filetype["ruby"] = { - function() - return { - exe = O.lang.ruby.formatter.exe, - args = O.lang.ruby.formatter.args, - stdin = O.lang.ruby.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - ruby = O.lang.ruby.linters, - } -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "sorbet" then - require("lspconfig").sorbet.setup {} - end - - if not require("lv-utils").check_lsp_client_active "solargraph" then - -- If you are using rvm, make sure to change below configuration - require("lspconfig").solargraph.setup { - cmd = { O.lang.ruby.lsp.path, "stdio" }, - on_attach = require("lsp").common_on_attach, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.ruby.diagnostics.virtual_text, - signs = O.lang.ruby.diagnostics.signs, - underline = O.lang.ruby.diagnostics.underline, - update_in_insert = true, - }), - }, - filetypes = O.lang.ruby.filetypes, - } - end -end - -M.dap = function() - -- gem install readapt ruby-debug-ide - if O.plugin.dap.active then - local dap_install = require "dap-install" - dap_install.config("ruby_vsc_dbg", {}) - end -end - -return M diff --git a/lua/lang/rust.lua b/lua/lang/rust.lua deleted file mode 100644 index e3d4ce47..00000000 --- a/lua/lang/rust.lua +++ /dev/null @@ -1,155 +0,0 @@ -local M = {} - -M.config = function() - O.lang.rust = { - rust_tools = { - active = false, - parameter_hints_prefix = "<-", - other_hints_prefix = "=>", -- prefix for all the other hints (type, chaining) - }, - -- @usage can be clippy - formatter = { - exe = "rustfmt", - args = { "--emit=stdout", "--edition=2018" }, - stdin = true, - }, - linter = "", - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/rust/rust-analyzer", - }, - } -end - -M.format = function() - O.formatters.filetype["rust"] = { - function() - return { - exe = O.lang.rust.formatter.exe, - args = O.lang.rust.formatter.args, - stdin = O.lang.rust.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "rust_analyzer" then - return - end - - if O.lang.rust.rust_tools.active then - local opts = { - tools = { -- rust-tools options - -- automatically set inlay hints (type hints) - -- There is an issue due to which the hints are not applied on the first - -- opened file. For now, write to the file to trigger a reapplication of - -- the hints or just run :RustSetInlayHints. - -- default: true - autoSetHints = true, - - -- whether to show hover actions inside the hover window - -- this overrides the default hover handler - -- default: true - hover_with_actions = true, - - runnables = { - -- whether to use telescope for selection menu or not - -- default: true - use_telescope = true, - - -- rest of the opts are forwarded to telescope - }, - - inlay_hints = { - -- wheter to show parameter hints with the inlay hints or not - -- default: true - show_parameter_hints = true, - - -- prefix for parameter hints - -- default: "<-" - parameter_hints_prefix = O.lang.rust.rust_tools.parameter_hints_prefix, - - -- prefix for all the other hints (type, chaining) - -- default: "=>" - other_hints_prefix = O.lang.rust.rust_tools.other_hints_prefix, - - -- whether to align to the lenght of the longest line in the file - max_len_align = false, - - -- padding from the left if max_len_align is true - max_len_align_padding = 1, - - -- whether to align to the extreme right or not - right_align = false, - - -- padding from the right if right_align is true - right_align_padding = 7, - }, - - hover_actions = { - -- the border that is used for the hover window - -- see vim.api.nvim_open_win() - border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - }, - }, - }, - - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim - -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer - server = { - cmd = { O.lang.rust.lsp.path }, - on_attach = require("lsp").common_on_attach, - }, -- rust-analyser options - } - require("rust-tools").setup(opts) - else - require("lspconfig").rust_analyzer.setup { - cmd = { O.lang.rust.lsp.path }, - on_attach = require("lsp").common_on_attach, - filetypes = { "rust" }, - root_dir = require("lspconfig.util").root_pattern("Cargo.toml", "rust-project.json"), - } - end - - -- TODO: fix these mappings - vim.api.nvim_exec( - [[ - autocmd Filetype rust nnoremap lm RustExpandMacro - autocmd Filetype rust nnoremap lH RustToggleInlayHints - autocmd Filetype rust nnoremap le RustRunnables - autocmd Filetype rust nnoremap lh RustHoverActions - ]], - true - ) -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/scala.lua b/lua/lang/scala.lua deleted file mode 100644 index 081c74bf..00000000 --- a/lua/lang/scala.lua +++ /dev/null @@ -1,80 +0,0 @@ -local M = {} - -M.config = function() - O.lang.scala = { - metals = { - active = false, - server_version = "0.10.5", - excluded_packages = {}, - show_implicit_arguments = false, - show_inferred_type = true, - status_bar_provider = false, - }, - formatter = { - exe = "scalafmt", - args = { "--stdin" }, - stdin = true, - }, - } -end - -M.format = function() - O.formatters.filetype["scala"] = { - function() - return { - exe = O.lang.scala.formatter.exe, - args = O.lang.scala.formatter.args, - stdin = O.lang.scala.formatter.stdin, - } - end, - } - O.formatters.filetype["sbt"] = O.formatters.filetype["scala"] - -- To understand sbt files on stdin, scalafmt needs to assume any old filename - -- that ends in .sbt. Using a dummy filename instead of the actual one is - -- required to support buffers of sbt filetype without the extension. - O.formatters.filetype["sbt"].args = { "--stdin", "--assume-filename", "foo.sbt" } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - -- enable metal server integration - if O.lang.scala.metals.active then - vim.g["metals_server_version"] = O.lang.scala.metals.server_version - -- https://github.com/scalameta/nvim-metals#prerequisites - vim.opt_global.shortmess:remove("F"):append "c" - local metals_config = require("metals").bare_config - metals_config.on_attach = function() - require("completion").on_attach() - end - metals_config.handlers["textDocument/publishDiagnostics"] = - vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = { - prefix = "", - }, - }) - metals_config.settings = { - showImplicitArguments = O.lang.scala.metals.show_implicit_arguments, - showInferredType = O.lang.scala.metals.show_inferred_type, - excludedPackages = O.lang.scala.metals.excluded_packages, - } - metals_config.init_options.statusBarProvider = O.lang.scala.metals.status_bar_provider - require "lsp" - require("metals").initialize_or_attach(metals_config) - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/sh.lua b/lua/lang/sh.lua deleted file mode 100644 index 71170e1f..00000000 --- a/lua/lang/sh.lua +++ /dev/null @@ -1,65 +0,0 @@ -local M = {} - -M.config = function() - O.lang.sh = { - -- @usage can be 'shellcheck' - linter = "", - -- @usage can be 'shfmt' - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - formatter = { - exe = "shfmt", - args = { "-w" }, - stdin = false, - }, - linters = { "shellcheck" }, - lsp = { - path = DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", - }, - } -end - -M.format = function() - O.formatters.filetype["sh"] = { - function() - return { - exe = O.lang.sh.formatter.exe, - args = O.lang.sh.formatter.args, - stdin = O.lang.sh.formatter.stdin, - tempfile_prefix = ".formatter", - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - require("lint").linters_by_ft = { - sh = O.lang.sh.linters, - } -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "bashls" then - -- npm i -g bash-language-server - require("lspconfig").bashls.setup { - cmd = { O.lang.sh.lsp.path, "start" }, - on_attach = require("lsp").common_on_attach, - filetypes = { "sh", "zsh" }, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/svelte.lua b/lua/lang/svelte.lua deleted file mode 100644 index ad6dd094..00000000 --- a/lua/lang/svelte.lua +++ /dev/null @@ -1,39 +0,0 @@ -local M = {} - -M.config = function() - O.lang.svelte = { - lsp = { - path = DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", - }, - } -end - -M.format = function() - -- TODO: implement formatter (if applicable) - return "No formatter configured!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "svelte" then - return - end - - require("lspconfig").svelte.setup { - cmd = { O.lang.svelte.lsp.path, "--stdio" }, - filetypes = { "svelte" }, - root_dir = require("lspconfig.util").root_pattern("package.json", ".git"), - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/swift.lua b/lua/lang/swift.lua deleted file mode 100644 index 845f9a49..00000000 --- a/lua/lang/swift.lua +++ /dev/null @@ -1,55 +0,0 @@ -local M = {} - -M.config = function() - O.lang.swift = { - formatter = { - exe = "swiftformat", - args = {}, - stdin = true, - }, - lsp = { - path = "sourcekit-lsp", - }, - } -end - -M.format = function() - -- TODO: implement formatter (if applicable) - return "No formatter configured!" -end - -M.lint = function() - O.formatters.filetype["swift"] = { - function() - return { - exe = O.lang.swift.formatter.exe, - args = O.lang.swift.formatter.args, - stdin = O.lang.swift.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "sourcekit" then - return - end - - require("lspconfig").sourcekit.setup { - cmd = { "xcrun", O.lang.swift.lsp.path }, - on_attach = require("lsp").common_on_attach, - filetypes = { "swift" }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/terraform.lua b/lua/lang/terraform.lua deleted file mode 100644 index df8ac692..00000000 --- a/lua/lang/terraform.lua +++ /dev/null @@ -1,57 +0,0 @@ -local M = {} - -M.config = function() - O.lang.terraform = { - formatter = { - exe = "terraform", - args = { "fmt" }, - stdin = false, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/terraform/terraform-ls", - }, - } -end - -M.format = function() - O.formatters.filetype["hcl"] = { - function() - return { - exe = O.lang.terraform.formatter.exe, - args = O.lang.terraform.formatter.args, - stdin = O.lang.terraform.formatter.stdin, - tempfile_prefix = ".formatter", - } - end, - } - O.formatters.filetype["tf"] = O.formatters.filetype["hcl"] - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "terraformls" then - return - end - - require("lspconfig").terraformls.setup { - cmd = { O.lang.terraform.lsp.path, "serve" }, - on_attach = require("lsp").common_on_attach, - filetypes = { "tf", "terraform", "hcl" }, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/tex.lua b/lua/lang/tex.lua deleted file mode 100644 index a91105ff..00000000 --- a/lua/lang/tex.lua +++ /dev/null @@ -1,159 +0,0 @@ -local M = {} - -M.config = function() - O.lang.latex = { - filetypes = { "tex", "bib" }, - aux_directory = nil, - bibtex_formatter = "texlab", - diagnostics_delay = 300, - formatter_line_length = 80, - latex_formatter = "latexindent", - lsp = { - path = DATA_PATH .. "/lspinstall/latex/texlab", - }, - build = { - executable = "latexmk", - args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" }, - on_save = false, - forward_search_after = false, - }, - chktex = { - on_open_and_save = false, - on_edit = false, - }, - forward_search = { - executable = nil, - args = {}, - }, - latexindent = { - ["local"] = nil, - modify_line_breaks = false, - }, - diagnostics = { - virtual_text = { spacing = 0, prefix = "" }, - signs = true, - underline = true, - }, - linters = { "chktex" }, - auto_save = false, - ignore_errors = {}, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - require("lint").linters_by_ft = { - tex = O.lang.latex.linters, - } -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "texlab" then - return - end - - local preview_settings = {} - - local sumatrapdf_args = { "-reuse-instance", "%p", "-forward-search", "%f", "%l" } - local evince_args = { "-f", "%l", "%p", '"code -g %f:%l"' } - local okular_args = { "--unique", "file:%p#src:%l%f" } - local zathura_args = { "--synctex-forward", "%l:1:%f", "%p" } - local qpdfview_args = { "--unique", "%p#src:%f:%l:1" } - local skim_args = { "%l", "%p", "%f" } - - if O.lang.latex.forward_search.executable == "C:/Users/{User}/AppData/Local/SumatraPDF/SumatraPDF.exe" then - preview_settings = sumatrapdf_args - elseif O.lang.latex.forward_search.executable == "evince-synctex" then - preview_settings = evince_args - elseif O.lang.latex.forward_search.executable == "okular" then - preview_settings = okular_args - elseif O.lang.latex.forward_search.executable == "zathura" then - preview_settings = zathura_args - elseif O.lang.latex.forward_search.executable == "qpdfview" then - preview_settings = qpdfview_args - elseif O.lang.latex.forward_search.executable == "/Applications/Skim.app/Contents/SharedSupport/displayline" then - preview_settings = skim_args - end - - require("lspconfig").texlab.setup { - cmd = { O.lang.latex.lsp.path }, - on_attach = require("lsp").common_on_attach, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.latex.diagnostics.virtual_text, - signs = O.lang.latex.diagnostics.signs, - underline = O.lang.latex.diagnostics.underline, - update_in_insert = true, - }), - }, - filetypes = { "tex", "bib" }, - settings = { - texlab = { - auxDirectory = O.lang.latex.aux_directory, - bibtexFormatter = O.lang.latex.bibtex_formatter, - build = { - args = O.lang.latex.build.args, - executable = O.lang.latex.build.executable, - forwardSearchAfter = O.lang.latex.build.forward_search_after, - onSave = O.lang.latex.build.on_save, - }, - chktex = { - onEdit = O.lang.latex.chktex.on_edit, - onOpenAndSave = O.lang.latex.chktex.on_open_and_save, - }, - diagnosticsDelay = O.lang.latex.diagnostics_delay, - formatterLineLength = O.lang.latex.formatter_line_length, - forwardSearch = { - args = preview_settings, - executable = O.lang.latex.forward_search.executable, - }, - latexFormatter = O.lang.latex.latex_formatter, - latexindent = { - modifyLineBreaks = O.lang.latex.latexindent.modify_line_breaks, - }, - }, - }, - } - vim.g.vimtex_compiler_method = "latexmk" - vim.g.vimtex_view_method = "zathura" - vim.g.vimtex_fold_enabled = 0 - vim.g.vimtex_quickfix_ignore_filters = O.lang.latex.ignore_errors - - O.plugin.which_key.mappings["t"] = { - name = "+Latex", - c = { "VimtexCompile", "Toggle Compilation Mode" }, - f = { "call vimtex#fzf#run()", "Fzf Find" }, - i = { "VimtexInfo", "Project Information" }, - s = { "VimtexStop", "Stop Project Compilation" }, - t = { "VimtexTocToggle", "Toggle Table Of Content" }, - v = { "VimtexView", "View PDF" }, - b = { "TexlabBuild", "Build with Texlab" }, - p = { "TexlabForward", "Preview with Texlab" }, - } - - -- Compile on initialization, cleanup on quit - vim.api.nvim_exec( - [[ - augroup vimtex_event_1 - au! - au User VimtexEventQuit call vimtex#compiler#clean(0) - au User VimtexEventInitPost call vimtex#compiler#compile() - augroup END - ]], - false - ) - if O.lang.latex.auto_save then - vim.api.nvim_exec([[au FocusLost * :wa]], false) - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/typescript.lua b/lua/lang/typescript.lua deleted file mode 100644 index 178c6f54..00000000 --- a/lua/lang/typescript.lua +++ /dev/null @@ -1,25 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/typescriptreact.lua b/lua/lang/typescriptreact.lua deleted file mode 100644 index 178c6f54..00000000 --- a/lua/lang/typescriptreact.lua +++ /dev/null @@ -1,25 +0,0 @@ -local M = {} - -M.config = function() - -- TODO: implement config for language - return "No config available!" -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/vim.lua b/lua/lang/vim.lua deleted file mode 100644 index 027538ab..00000000 --- a/lua/lang/vim.lua +++ /dev/null @@ -1,40 +0,0 @@ -local M = {} - -M.config = function() - O.lang.vim = { - linters = { "vint" }, - lsp = { - path = DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", - }, - } -end - -M.format = function() - -- TODO: implement formatter for language - return "No formatter available!" -end - -M.lint = function() - require("lint").linters_by_ft = { - vim = O.lang.vim.linters, - } -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "vimls" then - return - end - - -- npm install -g vim-language-server - require("lspconfig").vimls.setup { - cmd = { O.lang.vim.lsp.path, "--stdio" }, - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/vue.lua b/lua/lang/vue.lua deleted file mode 100644 index 8725bba2..00000000 --- a/lua/lang/vue.lua +++ /dev/null @@ -1,71 +0,0 @@ -local M = {} - -M.config = function() - O.lang.vue = { - formatter = { - exe = "prettier", - args = { - "--stdin-filepath", - "${FILEPATH}", - }, - stdin = true, - }, - auto_import = true, - lsp = { - path = DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", - }, - } -end - -M.format = function() - vim.cmd "let proj = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "proj" - - -- use the global formatter if you didn't find the local one - local formatter_instance = root_dir .. "/node_modules/.bin/" .. O.lang.vue.formatter.exe - if vim.fn.executable(formatter_instance) ~= 1 then - formatter_instance = O.lang.vue.formatter.exe - end - - local ft = vim.bo.filetype - O.formatters.filetype[ft] = { - function() - local lv_utils = require "lv-utils" - return { - exe = formatter_instance, - args = lv_utils.gsub_args(O.lang.vue.formatter.args), - stdin = O.lang.vue.formatter.stdin, - } - end, - } - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "vuels" then - return - end - - -- Vue language server configuration (vetur) - require("lspconfig").vuels.setup { - cmd = { O.lang.vue.lsp.path, "--stdio" }, - on_attach = require("lsp").common_on_attach, - } - - require("lsp.ts-fmt-lint").setup() -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/yaml.lua b/lua/lang/yaml.lua deleted file mode 100644 index 44366ad2..00000000 --- a/lua/lang/yaml.lua +++ /dev/null @@ -1,54 +0,0 @@ -local M = {} - -M.config = function() - O.lang.yaml = { - formatter = { - exe = "prettier", - args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, - stdin = true, - }, - lsp = { - path = DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", - }, - } -end - -M.format = function() - O.formatters.filetype["yaml"] = { - function() - return { - exe = O.lang.yaml.formatter.exe, - args = O.lang.yaml.formatter.args, - stdin = O.lang.yaml.formatter.stdin, - } - end, - } - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "yamlls" then - return - end - - -- npm install -g yaml-language-server - require("lspconfig").yamlls.setup { - cmd = { O.lang.yaml.lsp.path, "--stdio" }, - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/zig.lua b/lua/lang/zig.lua deleted file mode 100644 index 06ae9197..00000000 --- a/lua/lang/zig.lua +++ /dev/null @@ -1,58 +0,0 @@ -local M = {} - -M.config = function() - O.lang.zig = { - formatter = { - exe = "zig", - args = { "fmt" }, - stdin = false, - }, - lsp = { - path = "zls", - }, - } -end - -M.format = function() - O.formatters.filetype["zig"] = { - function() - return { - exe = O.lang.zig.formatter.exe, - args = O.lang.zig.formatter.args, - stdin = O.lang.zig.formatter.stdin, - } - end, - } - - require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, - } -end - -M.lint = function() - -- TODO: implement linters (if applicable) - return "No linters configured!" -end - -M.lsp = function() - if require("lv-utils").check_lsp_client_active "zls" then - return - end - -- Because lspinstall don't support zig yet, - -- So we need zls preset in global lib - -- Further custom install zls in - -- https://github.com/zigtools/zls/wiki/Downloading-and-Building-ZLS - require("lspconfig").zls.setup { - cmd = { O.lang.zig.lsp.path }, - root_dir = require("lspconfig").util.root_pattern(".git", "build.zig", "zls.json"), - on_attach = require("lsp").common_on_attach, - } -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lang/zsh.lua b/lua/lang/zsh.lua deleted file mode 100644 index 44ce35a1..00000000 --- a/lua/lang/zsh.lua +++ /dev/null @@ -1,53 +0,0 @@ -local M = {} - -M.config = function() - O.lang.zsh = { - lsp = { - path = DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", - }, - } -end - -M.format = function() - -- TODO: implement format for language - return "No format available!" -end - -M.lint = function() - -- zsh - local zsh_arguments = {} - - if not require("lv-utils").check_lsp_client_active "efm" then - require("lspconfig").efm.setup { - -- init_options = {initializationOptions}, - cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, - init_options = { documentFormatting = true, codeAction = false }, - root_dir = require("lspconfig").util.root_pattern ".git/", - filetypes = { "zsh" }, - settings = { - rootMarkers = { ".git/" }, - languages = { - zsh = zsh_arguments, - }, - }, - } - end -end - -M.lsp = function() - if not require("lv-utils").check_lsp_client_active "bashls" then - -- npm i -g bash-language-server - require("lspconfig").bashls.setup { - cmd = { O.lang.zsh.lsp.path, "start" }, - on_attach = require("lsp").common_on_attach, - filetypes = { "sh", "zsh" }, - } - end -end - -M.dap = function() - -- TODO: implement dap - return "No DAP configured!" -end - -return M diff --git a/lua/lsp/angular-ls.lua b/lua/lsp/angular-ls.lua deleted file mode 100644 index 818faf38..00000000 --- a/lua/lsp/angular-ls.lua +++ /dev/null @@ -1,6 +0,0 @@ --- TODO: find correct root filetype --- :LspInstall angular -require("lspconfig").angularls.setup { - cmd = { DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio" }, - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/emmet-ls.lua b/lua/lsp/emmet-ls.lua deleted file mode 100644 index e38747ac..00000000 --- a/lua/lsp/emmet-ls.lua +++ /dev/null @@ -1,23 +0,0 @@ --- if not package.loaded['lspconfig'] then --- return --- end - -local nvim_lsp = require "lspconfig" -local configs = require "lspconfig/configs" -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - -configs.emmet_ls = { - default_config = { - cmd = { "emmet-ls", "--stdio" }, - filetypes = { "html", "css", "javascript", "typescript", "vue" }, - root_dir = function() - return vim.loop.cwd() - end, - settings = {}, - }, -} - -nvim_lsp.emmet_ls.setup { - -- on_attach = on_attach; -} diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 7884f763..b0511f0e 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,4 +1,5 @@ --- TODO: figure out why this don't work +local lsp_config = {} + vim.fn.sign_define( "LspDiagnosticsSignError", { texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" } @@ -37,7 +38,7 @@ vim.fn.sign_define( -- { noremap = true, silent = true } -- ) -if O.lsp.default_keybinds then +if lvim.lsp.default_keybinds then vim.cmd "nnoremap gd lua vim.lsp.buf.definition()" vim.cmd "nnoremap gD lua vim.lsp.buf.declaration()" vim.cmd "nnoremap gr lua vim.lsp.buf.references()" @@ -51,8 +52,8 @@ if O.lsp.default_keybinds then vim.cmd "nnoremap gp lua require'lsp'.PeekDefinition()" vim.cmd "nnoremap K :lua vim.lsp.buf.hover()" - vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})" - vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})" + vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" + vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" vim.cmd "nnoremap lua vim.lsp.buf.signature_help()" -- scroll down hover doc or scroll in definition preview -- scroll up hover doc @@ -61,19 +62,21 @@ end -- Set Default Prefix. -- Note: You can set a prefix per lsp server in the lv-globals.lua file -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lsp.diagnostics.virtual_text, - signs = O.lsp.diagnostics.signs, - underline = O.lsp.document_highlight, -}) +function lsp_config.setup_handlers() + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = lvim.lsp.diagnostics.virtual_text, + signs = lvim.lsp.diagnostics.signs, + underline = lvim.lsp.document_highlight, + }) -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = O.lsp.popup_border, -}) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = lvim.lsp.popup_border, + }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = O.lsp.popup_border, -}) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = lvim.lsp.popup_border, + }) +end -- symbols for autocomplete vim.lsp.protocol.CompletionItemKind = { @@ -112,7 +115,7 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] -- autocmd FileType java nnoremap ca lua require('jdtls').code_action() local function lsp_highlight_document(client) - if O.lsp.document_highlight == false then + if lvim.lsp.document_highlight == false then return -- we don't need further end -- Set autocommands conditional on server_capabilities @@ -132,7 +135,6 @@ local function lsp_highlight_document(client) ) end end -local lsp_config = {} -- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ function lsp_config.preview_location(location, context, before_context) @@ -156,7 +158,7 @@ function lsp_config.preview_location(location, context, before_context) false ) local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") - return vim.lsp.util.open_floating_preview(contents, filetype, { border = O.lsp.popup_border }) + return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border }) end function lsp_config.preview_location_callback(_, method, result) @@ -200,12 +202,25 @@ function lsp_config.PeekImplementation() end function lsp_config.common_on_attach(client, bufnr) - if O.lsp.on_attach_callback then - O.lsp.on_attach_callback(client, bufnr) + if lvim.lsp.on_attach_callback then + lvim.lsp.on_attach_callback(client, bufnr) end lsp_highlight_document(client) end +function lsp_config.common_capabilities() + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + } + return capabilities +end + function lsp_config.tsserver_on_attach(client, _) -- lsp_config.common_on_attach(client, bufnr) client.resolved_capabilities.document_formatting = false @@ -222,13 +237,13 @@ function lsp_config.tsserver_on_attach(client, _) -- eslint eslint_enable_code_actions = true, eslint_enable_disable_comments = true, - -- eslint_bin = O.lang.tsserver.linter, + -- eslint_bin = lvim.lang.tsserver.linter, eslint_config_fallback = nil, eslint_enable_diagnostics = true, -- formatting - enable_formatting = O.lang.tsserver.autoformat, - formatter = O.lang.tsserver.formatter.exe, + enable_formatting = lvim.lang.tsserver.autoformat, + formatter = lvim.lang.tsserver.formatter.exe, formatter_config_fallback = nil, -- parentheses completion @@ -257,8 +272,15 @@ require("lv-utils").define_augroups { }, } --- Use a loop to conveniently both setup defined servers --- and map buffer local keybindings when the language server attaches --- local servers = {"pyright", "tsserver"} --- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +function lsp_config.setup(lang) + lang_server = lvim.lang[lang].lsp + require("lsp.null-ls").setup "python" + local provider = lang_server.provider + if require("lv-utils").check_lsp_client_active(provider) then + return + end + require("lspconfig")[provider].setup(lang_server.setup) + require("lsp.null-ls").setup(lang) +end + return lsp_config diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua new file mode 100644 index 00000000..43d4400a --- /dev/null +++ b/lua/lsp/null-ls.lua @@ -0,0 +1,70 @@ +local M = {} + +local null_ls = require "null-ls" +local sources = {} + +local local_executables = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } + +local function is_table(t) + return type(t) == "table" +end + +local function is_string(t) + return type(t) == "string" +end + +local function has_value(tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end + +local find_local_exe = function(exe) + vim.cmd "let root_dir = FindRootDirectory()" + local root_dir = vim.api.nvim_get_var "root_dir" + local local_exe = root_dir .. "/node_modules/.bin/" .. exe + return local_exe +end + +local function setup_ls(exe, type) + if has_value(local_executables, exe) then + local smart_executable = null_ls.builtins[type][exe] + local local_executable = find_local_exe(exe) + if vim.fn.executable(local_executable) then + smart_executable._opts.command = local_executable + end + table.insert(sources, smart_executable) + else + table.insert(sources, null_ls.builtins[type][exe]) + end + null_ls.register { sources = sources } +end + +local function setup(filetype, type) + if type == "diagnostics" then + executables = lvim.lang[filetype].linters + end + if type == "formatting" then + executables = lvim.lang[filetype].formatter.exe + end + + if is_table(executables) then + for _, exe in pairs(executables) do + setup_ls(exe, type) + end + end + if is_string(executables) then + setup_ls(executables, type) + end +end + +function M.setup(filetype) + setup(filetype, "formatting") + setup(filetype, "diagnostics") +end + +return M diff --git a/lua/lsp/svelte-ls.lua b/lua/lsp/svelte-ls.lua deleted file mode 100644 index e5ddb3b3..00000000 --- a/lua/lsp/svelte-ls.lua +++ /dev/null @@ -1,5 +0,0 @@ --- TODO: what is a svelte filetype -require("lspconfig").svelte.setup { - cmd = { DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio" }, - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua deleted file mode 100644 index 38c1e7cc..00000000 --- a/lua/lsp/tailwindcss-ls.lua +++ /dev/null @@ -1,13 +0,0 @@ --- TODO: what is a tailwindcss filetype -local lspconfig = require "lspconfig" - -lspconfig.tailwindcss.setup { - cmd = { - "node", - DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", - "--stdio", - }, - filetypes = O.lang.tailwindcss.filetypes, - root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua deleted file mode 100644 index 7cebfd86..00000000 --- a/lua/lsp/ts-fmt-lint.lua +++ /dev/null @@ -1,72 +0,0 @@ --- Example configuations here: https://github.com/mattn/efm-langserver -local M = {} - -M.setup = function() - vim.cmd "let proj = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "proj" - - local get_linter_instance = function() - -- prioritize local instance over global - local local_instance = root_dir .. "/node_modules/.bin/" .. O.lang.tsserver.linter - if vim.fn.executable(local_instance) == 1 then - return local_instance - end - return O.lang.tsserver.linter - end - - local tsserver_args = {} - local formattingSupported = false - - if O.lang.tsserver.linter == "eslint" or O.lang.tsserver.linter == "eslint_d" then - local eslint = { - lintCommand = get_linter_instance() .. " -f visualstudio --stdin --stdin-filename ${INPUT}", - lintStdin = true, - lintFormats = { - "%f(%l,%c): %tarning %m", - "%f(%l,%c): %trror %m", - }, - lintSource = O.lang.tsserver.linter, - lintIgnoreExitCode = true, - } - table.insert(tsserver_args, eslint) - -- Only eslint_d supports --fix-to-stdout - if string.find(get_linter_instance(), "eslint_d") then - formattingSupported = true - local eslint_fix = { - formatCommand = get_linter_instance() .. " --fix-to-stdout --stdin --stdin-filename ${INPUT}", - formatStdin = true, - } - table.insert(tsserver_args, eslint_fix) - end - end - - require("lspconfig").efm.setup { - -- init_options = {initializationOptions}, - cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, - init_options = { documentFormatting = formattingSupported, codeAction = false }, - root_dir = require("lspconfig").util.root_pattern(".git/", "package.json"), - filetypes = { - "vue", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "javascript.jsx", - "typescript.tsx", - }, - settings = { - rootMarkers = { ".git/", "package.json" }, - languages = { - vue = tsserver_args, - javascript = tsserver_args, - javascriptreact = tsserver_args, - ["javascript.jsx"] = tsserver_args, - typescript = tsserver_args, - ["typescript.tsx"] = tsserver_args, - typescriptreact = tsserver_args, - }, - }, - } -end - -return M diff --git a/lua/lsp/tsserver-ls.lua b/lua/lsp/tsserver-ls.lua deleted file mode 100644 index 18e56dae..00000000 --- a/lua/lsp/tsserver-ls.lua +++ /dev/null @@ -1,83 +0,0 @@ -vim.cmd "let proj = FindRootDirectory()" -local root_dir = vim.api.nvim_get_var "proj" - --- use the global prettier if you didn't find the local one -local prettier_instance = root_dir .. "/node_modules/.bin/prettier" -if vim.fn.executable(prettier_instance) ~= 1 then - prettier_instance = O.lang.tsserver.formatter.exe -end - -O.formatters.filetype["javascriptreact"] = { - function() - local args = { "--stdin-filepath", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) } - local extend_args = O.lang.tsserver.formatter.args - - if extend_args then - for i = 1, #extend_args do - table.insert(args, extend_args[i]) - end - end - - return { - exe = prettier_instance, - args = args, - stdin = true, - } - end, -} -O.formatters.filetype["javascript"] = O.formatters.filetype["javascriptreact"] -O.formatters.filetype["typescript"] = O.formatters.filetype["javascriptreact"] -O.formatters.filetype["typescriptreact"] = O.formatters.filetype["javascriptreact"] - -require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "tsserver" then - return -end - --- npm install -g typescript typescript-language-server --- require'snippets'.use_suggested_mappings() --- local capabilities = vim.lsp.protocol.make_client_capabilities() --- capabilities.textDocument.completion.completionItem.snippetSupport = true; --- local on_attach_common = function(client) --- print("LSP Initialized") --- require'completion'.on_attach(client) --- require'illuminate'.on_attach(client) --- end - -local on_attach = function(client, bufnr) - local lsp = require "lsp" - lsp.common_on_attach(client, bufnr) - lsp.tsserver_on_attach(client, bufnr) -end - -require("lspconfig").tsserver.setup { - cmd = { - DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", - "--stdio", - }, - filetypes = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", - }, - on_attach = on_attach, - -- This makes sure tsserver is not used for formatting (I prefer prettier) - settings = { documentFormatting = false }, - handlers = { - -- ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - -- virtual_text = O.lang.tsserver.diagnostics.virtual_text, - -- signs = O.lang.tsserver.diagnostics.signs, - -- underline = O.lang.tsserver.diagnostics.underline, - -- update_in_insert = true, - -- }), - }, -} - -require("lsp.ts-fmt-lint").setup() diff --git a/lua/lv-user/README.md b/lua/lv-user/README.md deleted file mode 100644 index 789001a2..00000000 --- a/lua/lv-user/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# User Config - -If you have found this directory then you are probably advanced enough to add your own config. All `lua` files you create here will be available in lv-config. - -**NOTE** I may update this readme in the future so I recommend not changing anything in this file specifically diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index 3dff8f2e..d97c7c30 100644 --- a/lua/lv-utils/init.lua +++ b/lua/lv-utils/init.lua @@ -56,14 +56,39 @@ function lv_utils.generate_settings() io.close(file) end +-- autoformat +local toggle_autoformat = function() + if lvim.format_on_save then + require("lv-utils").define_augroups { + autoformat = { + { + "BufWritePost", + "*", + ":silent lua vim.lsp.buf.formatting()", + }, + }, + } + end + + if not lvim.format_on_save then + vim.cmd [[if exists('#autoformat#BufWritePost') + :autocmd! autoformat + endif]] + end +end + +function lv_utils.toggle_autoformat() + toggle_autoformat() +end + function lv_utils.reload_lv_config() vim.cmd "source ~/.config/lvim/lv-config.lua" vim.cmd "source ~/.local/share/lunarvim/lvim/lua/plugins.lua" local plugins = require "plugins" local plugin_loader = require("plugin-loader").init() - plugin_loader:load { plugins, O.user_plugins } + toggle_autoformat() + plugin_loader:load { plugins, lvim.plugins } vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua" - vim.cmd "source ~/.local/share/lunarvim/lvim/lua/core/formatter.lua" vim.cmd ":PackerCompile" vim.cmd ":PackerInstall" -- vim.cmd ":PackerClean" @@ -163,10 +188,13 @@ lv_utils.define_augroups { { "BufWritePost", "lv-config.lua", "lua require('lv-utils').reload_lv_config()" }, -- { "VimLeavePre", "*", "set title set titleold=" }, }, - _solidity = { + _filetypechanges = { { "BufWinEnter", ".tf", "setlocal filetype=hcl" }, { "BufRead", "*.tf", "setlocal filetype=hcl" }, { "BufNewFile", "*.tf", "setlocal filetype=hcl" }, + { "BufWinEnter", ".zsh", "setlocal filetype=sh" }, + { "BufRead", "*.zsh", "setlocal filetype=sh" }, + { "BufNewFile", "*.zsh", "setlocal filetype=sh" }, }, -- _solidity = { -- {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'}, @@ -203,7 +231,7 @@ lv_utils.define_augroups { -- {'InsertEnter', '*', 'if &cursorline | let g:ms_cursorlineoff = 1 | setlocal nocursorline | endif'}, -- {'InsertLeave', '*', 'if exists("g:ms_cursorlineoff") | setlocal cursorline | endif'}, -- }, - _user_autocommands = O.user_autocommands, + _user_autocommands = lvim.autocommands, } function lv_utils.gsub_args(args) diff --git a/lua/plugins.lua b/lua/plugins.lua index 26b75431..7d2356d5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,17 +1,17 @@ return { -- Packer can manage itself as an optional plugin { "wbthomason/packer.nvim" }, - - -- TODO: refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function) { "neovim/nvim-lspconfig" }, + { "tamago324/nlsp-settings.nvim" }, + { "jose-elias-alvarez/null-ls.nvim" }, { "kabouzeid/nvim-lspinstall", event = "VimEnter", config = function() local lspinstall = require "lspinstall" lspinstall.setup() - if O.plugin.lspinstall.on_config_done then - O.plugin.lspinstall.on_config_done(lspinstall) + if lvim.builtin.lspinstall.on_config_done then + lvim.builtin.lspinstall.on_config_done(lspinstall) end end, }, @@ -25,8 +25,8 @@ return { "nvim-telescope/telescope.nvim", config = function() require("core.telescope").setup() - if O.plugin.telescope.on_config_done then - O.plugin.telescope.on_config_done(require "telescope") + if lvim.builtin.telescope.on_config_done then + lvim.builtin.telescope.on_config_done(require "telescope") end end, }, @@ -37,8 +37,8 @@ return { -- event = "InsertEnter", config = function() require("core.compe").setup() - if O.plugin.compe.on_config_done then - O.plugin.compe.on_config_done(require "compe") + if lvim.builtin.compe.on_config_done then + lvim.builtin.compe.on_config_done(require "compe") end end, }, @@ -49,8 +49,8 @@ return { -- event = "InsertEnter", config = function() require "core.autopairs" - if O.plugin.autopairs.on_config_done then - O.plugin.autopairs.on_config_done(require "nvim-autopairs") + if lvim.builtin.autopairs.on_config_done then + lvim.builtin.autopairs.on_config_done(require "nvim-autopairs") end end, }, @@ -65,30 +65,8 @@ return { "nvim-treesitter/nvim-treesitter", config = function() require("core.treesitter").setup() - if O.plugin.treesitter.on_config_done then - O.plugin.treesitter.on_config_done(require "nvim-treesitter.configs") - end - end, - }, - - -- Formatter.nvim - { - "mhartington/formatter.nvim", - config = function() - require "core.formatter" - if O.plugin.formatter.on_config_done then - O.plugin.formatter.on_config_done(require "formatter") - end - end, - }, - - -- Linter - { - "mfussenegger/nvim-lint", - config = function() - require("core.linter").setup() - if O.plugin.lint.on_config_done then - O.plugin.lint.on_config_done(require "lint") + if lvim.builtin.treesitter.on_config_done then + lvim.builtin.treesitter.on_config_done(require "nvim-treesitter.configs") end end, }, @@ -101,8 +79,8 @@ return { -- commit = "fd7f60e242205ea9efc9649101c81a07d5f458bb", config = function() require("core.nvimtree").setup() - if O.plugin.nvimtree.on_config_done then - O.plugin.nvimtree.on_config_done(require "nvim-tree.config") + if lvim.builtin.nvimtree.on_config_done then + lvim.builtin.nvimtree.on_config_done(require "nvim-tree.config") end end, }, @@ -112,20 +90,20 @@ return { config = function() require("core.gitsigns").setup() - if O.plugin.gitsigns.on_config_done then - O.plugin.gitsigns.on_config_done(require "gitsigns") + if lvim.builtin.gitsigns.on_config_done then + lvim.builtin.gitsigns.on_config_done(require "gitsigns") end end, event = "BufRead", }, - -- whichkey + -- Whichkey { "folke/which-key.nvim", config = function() require("core.which-key").setup() - if O.plugin.which_key.on_config_done then - O.plugin.which_key.on_config_done(require "which-key") + if lvim.builtin.which_key.on_config_done then + lvim.builtin.which_key.on_config_done(require "which-key") end end, event = "BufWinEnter", @@ -141,8 +119,8 @@ return { return end nvim_comment.setup() - if O.plugin.comment.on_config_done then - O.plugin.comment.on_config_done(nvim_comment) + if lvim.builtin.comment.on_config_done then + lvim.builtin.comment.on_config_done(nvim_comment) end end, }, @@ -152,8 +130,8 @@ return { "airblade/vim-rooter", config = function() vim.g.rooter_silent_chdir = 1 - if O.plugin.rooter.on_config_done then - O.plugin.rooter.on_config_done() + if lvim.builtin.rooter.on_config_done then + lvim.builtin.rooter.on_config_done() end end, }, @@ -166,20 +144,20 @@ return { "glepnir/galaxyline.nvim", config = function() require "core.galaxyline" - if O.plugin.galaxyline.on_config_done then - O.plugin.galaxyline.on_config_done(require "galaxyline") + if lvim.builtin.galaxyline.on_config_done then + lvim.builtin.galaxyline.on_config_done(require "galaxyline") end end, event = "BufWinEnter", - disable = not O.plugin.galaxyline.active, + disable = not lvim.builtin.galaxyline.active, }, { "romgrk/barbar.nvim", config = function() require "core.bufferline" - if O.plugin.bufferline.on_config_done then - O.plugin.bufferline.on_config_done() + if lvim.builtin.bufferline.on_config_done then + lvim.builtin.bufferline.on_config_done() end end, event = "BufWinEnter", @@ -191,11 +169,11 @@ return { -- event = "BufWinEnter", config = function() require("core.dap").setup() - if O.plugin.dap.on_config_done then - O.plugin.dap.on_config_done(require "dap") + if lvim.builtin.dap.on_config_done then + lvim.builtin.dap.on_config_done(require "dap") end end, - disable = not O.plugin.dap.active, + disable = not lvim.builtin.dap.active, }, -- Debugger management @@ -203,102 +181,32 @@ return { "Pocco81/DAPInstall.nvim", -- event = "BufWinEnter", -- event = "BufRead", - disable = not O.plugin.dap.active, + disable = not lvim.builtin.dap.active, }, - -- Builtins, these do not load by default - -- Dashboard { "ChristianChiarulli/dashboard-nvim", event = "BufWinEnter", config = function() require("core.dashboard").setup() - if O.plugin.dashboard.on_config_done then - O.plugin.dashboard.on_config_done(require "dashboard") + if lvim.builtin.dashboard.on_config_done then + lvim.builtin.dashboard.on_config_done(require "dashboard") end end, - disable = not O.plugin.dashboard.active, + disable = not lvim.builtin.dashboard.active, }, - -- TODO: remove in favor of akinsho/nvim-toggleterm.lua - -- Floating terminal - -- { - -- "numToStr/FTerm.nvim", - -- event = "BufWinEnter", - -- config = function() - -- require("core.floatterm").setup() - -- end, - -- disable = not O.plugin.floatterm.active, - -- }, - + -- Terminal { "akinsho/nvim-toggleterm.lua", event = "BufWinEnter", config = function() require("core.terminal").setup() - if O.plugin.terminal.on_config_done then - O.plugin.terminal.on_config_done(require "toggleterm") + if lvim.builtin.terminal.on_config_done then + lvim.builtin.terminal.on_config_done(require "toggleterm") end end, - disable = not O.plugin.terminal.active, - }, - - -- Zen Mode - { - "folke/zen-mode.nvim", - cmd = "ZenMode", - event = "BufRead", - config = function() - require("core.zen").setup() - if O.plugin.zen.on_config_done then - O.plugin.zen.on_config_done(require "zen-mode") - end - end, - disable = not O.plugin.zen.active, - }, - - --------------------------------------------------------------------------------- - - -- LANGUAGE SPECIFIC GOES HERE - { - "lervag/vimtex", - ft = "tex", - }, - - -- Rust tools - -- TODO: use lazy loading maybe? - { - "simrat39/rust-tools.nvim", - disable = not O.lang.rust.rust_tools.active, - }, - - -- Elixir - { "elixir-editors/vim-elixir", ft = { "elixir", "eelixir", "euphoria3" } }, - - -- Javascript / Typescript - { - "jose-elias-alvarez/nvim-lsp-ts-utils", - ft = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", - }, - }, - - -- Java - { - "mfussenegger/nvim-jdtls", - -- ft = { "java" }, - disable = not O.lang.java.java_tools.active, - }, - - -- Scala - { - "scalameta/nvim-metals", - disable = not O.lang.scala.metals.active, + disable = not lvim.builtin.terminal.active, }, } diff --git a/lua/settings.lua b/lua/settings.lua index aa2bdd8d..f1075e1d 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -3,18 +3,57 @@ local cmd = vim.cmd local opt = vim.opt ---- VIM ONLY COMMANDS --- +local default_options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 2, -- more space in the neovim command line for displaying messages + colorcolumn = "99999", -- fixes indentline for now + completeopt = { "menuone", "noselect" }, + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + foldmethod = "manual", -- folding, set to "expr" for treesitter based foloding + foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding + guifont = "monospace:h17", -- the font used in graphical neovim applications + hidden = true, -- required to keep multiple buffers and open multiple buffers + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + mouse = "a", -- allow the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = false, -- we don't need to see things like -- INSERT -- anymore + showtabline = 2, -- always show tabs + smartcase = true, -- smart case + smartindent = true, -- make indenting smarter again + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds) + title = true, -- set the title of window to the value of the titlestring + -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to + undodir = CACHE_PATH .. "/undo", -- set an undo directory + undofile = true, -- enable persisten undo + updatetime = 300, -- faster completion + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + relativenumber = false, -- set relative numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + wrap = false, -- display lines as one long line + spell = false, + spelllang = "en", + scrolloff = 8, -- is one of my fav + sidescrolloff = 8, +} --- VIM ONLY COMMANDS ---cmd "filetype plugin on"cmd('let &titleold="' .. TERMINAL .. '"')cmd "set inccommand=split"cmd "set iskeyword+=-" -cmd "filetype plugin on" -cmd('let &titleold="' .. TERMINAL .. '"') -cmd "set inccommand=split" -cmd "set iskeyword+=-" - -if O.line_wrap_cursor_movement then +if lvim.line_wrap_cursor_movement then cmd "set whichwrap+=<,>,[,],h,l" end -if O.transparent_window then +if lvim.transparent_window then cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" cmd "au ColorScheme * hi NormalNC ctermbg=none guibg=none" @@ -28,10 +67,6 @@ end opt.shortmess:append "c" -for _, plugin in pairs(O.disabled_built_ins) do - vim.g["loaded_" .. plugin] = 1 -end - -for k, v in pairs(O.default_options) do +for k, v in pairs(default_options) do vim.opt[k] = v end diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 9ec19bd5..3d7fcc33 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -124,8 +124,13 @@ cloneconfig() { +PackerSync printf "\nCompile Complete\n" - rm "$HOME/.config/lvim/lv-config.lua" - cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example.lua" "$HOME/.config/lvim/lv-config.lua" + + if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then + echo 'lv-config already present' + else + cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example.lua" "$HOME/.config/lvim/lv-config.lua" + fi + } asktoinstallnode() { diff --git a/utils/installer/lv-config.example-no-ts.lua b/utils/installer/lv-config.example-no-ts.lua index 4016582c..b1e3bc8a 100644 --- a/utils/installer/lv-config.example-no-ts.lua +++ b/utils/installer/lv-config.example-no-ts.lua @@ -10,16 +10,14 @@ an executable -- general -O.format_on_save = true -O.lint_on_save = true -O.completion.autocomplete = true -O.colorscheme = "spacegray" -O.default_options.wrap = true -O.default_options.timeoutlen = 100 +lvim.format_on_save = true +lvim.lint_on_save = true +lvim.completion.autocomplete = true +lvim.colorscheme = "spacegray" -- keymappings -O.keys.leader_key = "space" +lvim.leader = "space" -- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them --- O.keys.normal_mode = { +-- lvim.keys.normal_mode = { -- Page down/up -- {'[d', ''}, -- {']d', ''}, @@ -38,22 +36,20 @@ O.keys.leader_key = "space" -- TODO: User Config for predefined plugins -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -O.plugin.dashboard.active = true -O.plugin.terminal.active = true -O.plugin.zen.active = false -O.plugin.zen.window.height = 0.90 -O.plugin.nvimtree.side = "left" -O.plugin.nvimtree.show_icons.git = 0 +lvim.builtin.dashboard.active = true +lvim.builtin.terminal.active = true +lvim.builtin.nvimtree.side = "left" +lvim.builtin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want -O.treesitter.ensure_installed = {} -O.treesitter.ignore_install = { "haskell" } -O.treesitter.highlight.enabled = true +lvim.treesitter.ensure_installed = {} +lvim.treesitter.ignore_install = { "haskell" } +lvim.treesitter.highlight.enabled = true -- generic LSP settings -- you can set a custom on_attach function that will be used for all the language servers -- See --- O.lsp.on_attach_callback = function(client, bufnr) +-- lvim.lsp.on_attach_callback = function(client, bufnr) -- local function buf_set_option(...) -- vim.api.nvim_buf_set_option(bufnr, ...) -- end @@ -61,29 +57,8 @@ O.treesitter.highlight.enabled = true -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end --- python -O.lang.python.diagnostics.virtual_text = true -O.lang.python.analysis.use_library_code_types = true --- To change default formatter from yapf to black --- O.lang.python.formatter.exe = "black" --- O.lang.python.formatter.args = {"-"} --- To change enabled linters --- https://github.com/mfussenegger/nvim-lint#available-linters --- O.lang.python.linters = { "flake8", "pylint", "mypy", ... } - --- go --- To change default formatter from gofmt to goimports --- O.lang.formatter.go.exe = "goimports" - --- javascript -O.lang.tsserver.linter = nil - --- latex --- O.lang.latex.auto_save = false --- O.lang.latex.ignore_errors = { } - -- Additional Plugins --- O.user_plugins = { +-- lvim.plugins = { -- {"folke/tokyonight.nvim"}, { -- "ray-x/lsp_signature.nvim", -- config = function() require"lsp_signature".on_attach() end, @@ -92,13 +67,6 @@ O.lang.tsserver.linter = nil -- } -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- lvim.autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} -- Additional Leader bindings for WhichKey --- O.user_which_key = { --- A = { --- name = "+Custom Leader Keys", --- a = { "echo 'first custom command'", "Description for a" }, --- b = { "echo 'second custom command'", "Description for b" }, --- }, --- } diff --git a/utils/installer/lv-config.example.lua b/utils/installer/lv-config.example.lua index 5754b160..027b1b86 100644 --- a/utils/installer/lv-config.example.lua +++ b/utils/installer/lv-config.example.lua @@ -10,16 +10,14 @@ an executable -- general -O.format_on_save = true -O.lint_on_save = true -O.completion.autocomplete = true -O.colorscheme = "spacegray" -O.default_options.wrap = true -O.default_options.timeoutlen = 100 +lvim.format_on_save = true +lvim.lint_on_save = true +lvim.completion.autocomplete = true +lvim.colorscheme = "spacegray" -- keymappings -O.keys.leader_key = "space" +lvim.leader = "space" -- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them --- O.keys.normal_mode = { +-- lvim.keys.normal_mode = { -- Page down/up -- {'[d', ''}, -- {']d', ''}, @@ -38,22 +36,20 @@ O.keys.leader_key = "space" -- TODO: User Config for predefined plugins -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -O.plugin.dashboard.active = true -O.plugin.terminal.active = true -O.plugin.zen.active = false -O.plugin.zen.window.height = 0.90 -O.plugin.nvimtree.side = "left" -O.plugin.nvimtree.show_icons.git = 0 +lvim.builtin.dashboard.active = true +lvim.builtin.terminal.active = true +lvim.builtin.nvimtree.side = "left" +lvim.builtin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want -O.treesitter.ensure_installed = "maintained" -O.treesitter.ignore_install = { "haskell" } -O.treesitter.highlight.enabled = true +lvim.treesitter.ensure_installed = "maintained" +lvim.treesitter.ignore_install = { "haskell" } +lvim.treesitter.highlight.enabled = true -- generic LSP settings -- you can set a custom on_attach function that will be used for all the language servers -- See --- O.lsp.on_attach_callback = function(client, bufnr) +-- lvim.lsp.on_attach_callback = function(client, bufnr) -- local function buf_set_option(...) -- vim.api.nvim_buf_set_option(bufnr, ...) -- end @@ -62,54 +58,9 @@ O.treesitter.highlight.enabled = true -- end -- python -O.lang.python.diagnostics.virtual_text = true -O.lang.python.analysis.use_library_code_types = true --- To change default formatter from yapf to black --- O.lang.python.formatter.exe = "black" --- O.lang.python.formatter.args = {"-"} --- To change enabled linters --- https://github.com/mfussenegger/nvim-lint#available-linters --- O.lang.python.linters = { "flake8", "pylint", "mypy", ... } - --- go --- To change default formatter from gofmt to goimports --- O.lang.formatter.go.exe = "goimports" - --- javascript -O.lang.tsserver.linter = nil - --- rust --- O.lang.rust.rust_tools = true --- O.lang.rust.formatter = { --- exe = "rustfmt", --- args = {"--emit=stdout", "--edition=2018"}, --- } - --- scala --- O.lang.scala.metals.active = true --- O.lang.scala.metals.server_version = "0.10.5", - ---LaTeX --- Options: https://github.com/latex-lsp/texlab/blob/master/docs/options.md -O.lang.latex.active = true -O.lang.latex.aux_directory = "." -O.lang.latex.bibtex_formatter = "texlab" -O.lang.latex.build.args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" } -O.lang.latex.build.executable = "latexmk" -O.lang.latex.build.forward_search_after = false -O.lang.latex.build.on_save = false -O.lang.latex.chktex.on_edit = false -O.lang.latex.chktex.on_open_and_save = false -O.lang.latex.diagnostics_delay = 300 -O.lang.latex.formatter_line_length = 80 -O.lang.latex.forward_search.executable = "zathura" -O.lang.latex.latex_formatter = "latexindent" -O.lang.latex.latexindent.modify_line_breaks = false --- O.lang.latex.auto_save = false --- O.lang.latex.ignore_errors = { } -- Additional Plugins --- O.user_plugins = { +-- lvim.plugins = { -- {"folke/tokyonight.nvim"}, { -- "ray-x/lsp_signature.nvim", -- config = function() require"lsp_signature".on_attach() end, @@ -118,13 +69,6 @@ O.lang.latex.latexindent.modify_line_breaks = false -- } -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- lvim.autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} -- Additional Leader bindings for WhichKey --- O.user_which_key = { --- A = { --- name = "+Custom Leader Keys", --- a = { "echo 'first custom command'", "Description for a" }, --- b = { "echo 'second custom command'", "Description for b" }, --- }, --- } diff --git a/utils/installer/uninstall.sh b/utils/installer/uninstall.sh new file mode 100755 index 00000000..faa76c37 --- /dev/null +++ b/utils/installer/uninstall.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +rm -rf .local/share/lunarvim +sudo rm /usr/local/bin/lvim diff --git a/lua/lsp/julia/Manifest.toml b/utils/julia/Manifest.toml similarity index 100% rename from lua/lsp/julia/Manifest.toml rename to utils/julia/Manifest.toml diff --git a/lua/lsp/julia/Project.toml b/utils/julia/Project.toml similarity index 100% rename from lua/lsp/julia/Project.toml rename to utils/julia/Project.toml diff --git a/lua/lsp/julia/run.jl b/utils/julia/run.jl similarity index 100% rename from lua/lsp/julia/run.jl rename to utils/julia/run.jl