Merge pull request #52 from marvelman3284/main

Added `lspinstall` functionality
This commit is contained in:
siduck76 2021-06-02 00:04:22 +05:30 committed by GitHub
commit 859a557297
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 60 deletions

View File

@ -1,4 +1,4 @@
local function map(mode, lhs, rhs, opts) local function map(mode, lhs, rhs, opts)
local options = {noremap = true} local options = {noremap = true}
if opts then if opts then
options = vim.tbl_extend("force", options, opts) options = vim.tbl_extend("force", options, opts)
@ -16,13 +16,12 @@ map("v", "dd", [=[ "_dd ]=], opt)
map("v", "x", [=[ "_x ]=], opt) map("v", "x", [=[ "_x ]=], opt)
this line too ]] this line too ]]
-- OPEN TERMINALS -- -- OPEN TERMINALS --
map("n", "<C-l>", [[<Cmd>vnew term://bash <CR>]], opt) -- over right map("n", "<C-l>", [[<Cmd>vnew term://bash <CR>]], opt) -- term over right
map("n", "<C-x>", [[<Cmd> split term://bash | resize 10 <CR>]], opt) -- bottom map("n", "<C-x>", [[<Cmd> split term://bash | resize 10 <CR>]], opt) -- term bottom
map("n", "<C-t>t", [[<Cmd> tabnew | term <CR>]], opt) -- newtab map("n", "<C-t>t", [[<Cmd> tabnew | term <CR>]], opt) -- term newtab
-- COPY EVERYTHING in the file-- -- COPY EVERYTHING --
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt) map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt)
-- toggle numbers --- -- toggle numbers ---
@ -32,4 +31,5 @@ map("n", "<leader>n", [[ <Cmd> set nu!<CR>]], opt)
map("n", "<leader>z", [[ <Cmd> TZAtaraxis<CR>]], opt) map("n", "<leader>z", [[ <Cmd> TZAtaraxis<CR>]], opt)
map("n", "<leader>m", [[ <Cmd> TZMinimalist<CR>]], opt) map("n", "<leader>m", [[ <Cmd> TZMinimalist<CR>]], opt)
map("n", "<C-s>", [[ <Cmd> w <CR>]], opt) -- save map("n", "<C-s>", [[ <Cmd> w <CR>]], opt)
-- vim.cmd("inoremap jh <Esc>")

View File

@ -1,4 +1,4 @@
function on_attach(client) function on_attach(client)
local function buf_set_keymap(...) local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...) vim.api.nvim_buf_set_keymap(bufnr, ...)
end end
@ -35,56 +35,53 @@ function on_attach(client)
end end
end end
local lspconf = require("lspconfig") -- lspInstall + lspconfig stuff
-- these langs require same lspconfig so put em all in a table and loop through! local function setup_servers()
local servers = {"html", "cssls", "tsserver", "pyright", "bashls", "clangd", "ccls"} require "lspinstall".setup()
for _, lang in ipairs(servers) do local lspconf = require("lspconfig")
lspconf[lang].setup { local servers = require "lspinstall".installed_servers()
on_attach = on_attach,
root_dir = vim.loop.cwd for _, lang in pairs(servers) do
} if lang ~= "lua" then
lspconf[lang].setup {
on_attach = on_attach,
root_dir = vim.loop.cwd
}
elseif lang == "lua" then
lspconf.sumneko_lua.setup {
root_dir = function()
return vim.loop.cwd()
end,
settings = {
Lua = {
diagnostics = {
globals = {"vim"}
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true
}
},
telemetry = {
enable = false
}
}
}
}
end
end
end end
-- vls conf example setup_servers()
local vls_binary = "/usr/local/bin/vls"
lspconf.vls.setup {
cmd = {vls_binary}
}
-- lua lsp settings -- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
USER = "/home/" .. vim.fn.expand("$USER") require "lspinstall".post_install_hook = function()
setup_servers() -- reload installed servers
local sumneko_root_path = USER .. "/.config/lua-language-server" vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
local sumneko_binary = USER .. "/.config/lua-language-server/bin/Linux/lua-language-server" end
lspconf.sumneko_lua.setup {
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
root_dir = function()
return vim.loop.cwd()
end,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = vim.split(package.path, ";")
},
diagnostics = {
globals = {"vim"}
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true
}
},
telemetry = {
enable = false
}
}
}
}
-- replace the default lsp diagnostic letters with prettier symbols -- replace the default lsp diagnostic letters with prettier symbols
vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"}) vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"})

View File

@ -9,15 +9,15 @@ return require("packer").startup(
-- color related stuff -- color related stuff
use "siduck76/nvim-base16.lua" use "siduck76/nvim-base16.lua"
use "norcalli/nvim-colorizer.lua" use "norcalli/nvim-colorizer.lua"
-- use "ollykel/v-vim" -- v syntax highlighter
-- lsp stuff -- lang stuff
use "nvim-treesitter/nvim-treesitter" use "nvim-treesitter/nvim-treesitter"
use "neovim/nvim-lspconfig" use "neovim/nvim-lspconfig"
use "hrsh7th/nvim-compe" use "hrsh7th/nvim-compe"
use "onsails/lspkind-nvim" use "onsails/lspkind-nvim"
use "sbdchd/neoformat" use "sbdchd/neoformat"
use "nvim-lua/plenary.nvim" use "nvim-lua/plenary.nvim"
use "kabouzeid/nvim-lspinstall"
use "lewis6991/gitsigns.nvim" use "lewis6991/gitsigns.nvim"
use "akinsho/nvim-bufferline.lua" use "akinsho/nvim-bufferline.lua"
@ -43,15 +43,11 @@ return require("packer").startup(
use "karb94/neoscroll.nvim" use "karb94/neoscroll.nvim"
use "kdav5758/TrueZen.nvim" use "kdav5758/TrueZen.nvim"
use "folke/which-key.nvim" use "folke/which-key.nvim"
-- discord rich presence
--use "andweeb/presence.nvim"
use {"lukas-reineke/indent-blankline.nvim", branch = "lua"} use {"lukas-reineke/indent-blankline.nvim", branch = "lua"}
end, end,
{ {
display = { display = {
border = { "", "", "", "", "", "", "", "" } border = {"", "", "", "", "", "", "", ""}
} }
} }
) )