minimal_rtp.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. vim.cmd [[set runtimepath=$VIMRUNTIME]]
  2. vim.cmd [[set packpath=/tmp/nvim/site]]
  3. local package_root = "/tmp/nvim/site/pack"
  4. local install_path = package_root .. "/packer/start/packer.nvim"
  5. local function load_plugins()
  6. require("packer").startup {
  7. {
  8. "wbthomason/packer.nvim",
  9. "neovim/nvim-lspconfig",
  10. {
  11. "aserowy/tmux.nvim",
  12. config = function()
  13. require("tmux").setup {
  14. navigation = {
  15. -- cycles to opposite pane while navigating into the border
  16. cycle_navigation = true,
  17. -- enables default keybindings (C-hjkl) for normal mode
  18. enable_default_keybindings = true,
  19. -- prevents unzoom tmux when navigating beyond vim border
  20. persist_zoom = true,
  21. },
  22. resize = {
  23. -- enables default keybindings (A-hjkl) for normal mode
  24. enable_default_keybindings = true,
  25. },
  26. }
  27. end,
  28. },
  29. },
  30. config = {
  31. package_root = package_root,
  32. compile_path = install_path .. "/plugin/packer_compiled.lua",
  33. },
  34. }
  35. end
  36. _G.load_config = function()
  37. vim.lsp.set_log_level "trace"
  38. local nvim_lsp = require "lspconfig"
  39. local on_attach = function(_, bufnr)
  40. local function buf_set_keymap(...)
  41. vim.api.nvim_buf_set_keymap(bufnr, ...)
  42. end
  43. local function buf_set_option(...)
  44. vim.api.nvim_buf_set_option(bufnr, ...)
  45. end
  46. buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
  47. -- Mappings.
  48. local opts = { noremap = true, silent = true }
  49. buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
  50. buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
  51. buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
  52. buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
  53. buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
  54. buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
  55. buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
  56. buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
  57. buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
  58. buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
  59. buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
  60. buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
  61. buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
  62. buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
  63. buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
  64. buf_set_keymap("n", "<space>li", "<cmd>LspInfo<CR>", opts)
  65. end
  66. -- Add the server that troubles you here
  67. local name = "sumneko_lua"
  68. local sumneko_root_dir = vim.fn.stdpath "data" .. "/lsp_servers/sumneko_lua/extension/server"
  69. local cmd = { sumneko_root_dir .. "/bin/Linux/lua-language-server", "-E", sumneko_root_dir .. "/main.lua" }
  70. if not name then
  71. print "You have not defined a server name, please edit minimal_init.lua"
  72. end
  73. if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
  74. print [[You have not defined a server default cmd for a server
  75. that requires it please edit minimal_init.lua]]
  76. end
  77. nvim_lsp[name].setup {
  78. cmd = cmd,
  79. on_attach = on_attach,
  80. }
  81. print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
  82. end
  83. if vim.fn.isdirectory(install_path) == 0 then
  84. vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
  85. load_plugins()
  86. require("packer").sync()
  87. vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
  88. else
  89. load_plugins()
  90. require("packer").sync()
  91. _G.load_config()
  92. end