1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Compare commits

..

No commits in common. "2880d7bce353e5e96e8f3f44e38982bf80ba6d69" and "ab88c112ffc6270e7b37e33cbc5181fa5c63f94d" have entirely different histories.

5 changed files with 25 additions and 48 deletions

View File

@ -120,35 +120,6 @@ fi
# Install bash-language-server # Install bash-language-server
"$NODE_DIR/bin/npm" install -g bash-language-server "$NODE_DIR/bin/npm" install -g bash-language-server
#######################################################################
# lua-language-server #
#######################################################################
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server
SUMNEKO_LUA_SRC_NAME=$HOME/packages/lua-language-server.tar.gz
SUMNEKO_LUA_LINK="https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-linux-x64.tar.gz"
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$SUMNEKO_LUA_DIR/bin/lua-language-server" ]]; then
echo 'Install lua-language-server'
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then
echo "Downloading lua-language-server and renaming"
wget $SUMNEKO_LUA_LINK -O "$SUMNEKO_LUA_SRC_NAME"
fi
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then
echo "Creating lua-language-server directory under tools directory"
mkdir -p "$SUMNEKO_LUA_DIR"
echo "Extracting to directory $SUMNEKO_LUA_DIR"
tar zxvf "$SUMNEKO_LUA_SRC_NAME" -C "$SUMNEKO_LUA_DIR"
fi
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
echo "export PATH=\"$SUMNEKO_LUA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi
else
echo "lua-language-server is already installed. Skip installing it."
fi
####################################################################### #######################################################################
# Ripgrep part # # Ripgrep part #
####################################################################### #######################################################################
@ -174,8 +145,8 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
fi fi
# set up manpath and zsh completion for ripgrep # set up manpath and zsh completion for ripgrep
mkdir -p "$HOME/tools/ripgrep/doc/man/man1" mkdir -p $HOME/tools/ripgrep/doc/man/man1
mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1" mv $HOME/tools/ripgrep/doc/rg.1 $HOME/tools/ripgrep/doc/man/man1
if [[ "$USE_BASH_SHELL" = true ]]; then if [[ "$USE_BASH_SHELL" = true ]]; then
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile" echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"

View File

@ -1 +0,0 @@
require"fidget".setup{}

View File

@ -13,7 +13,7 @@ local custom_attach = function(client, bufnr)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts) vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts) vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<space>wl", function() inspect(vim.lsp.buf.list_workspace_folders()) end, opts) vim.keymap.set("n", "<space>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts) vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
@ -21,10 +21,10 @@ local custom_attach = function(client, bufnr)
vim.keymap.set("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, opts) vim.keymap.set("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, opts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts) vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts)
api.nvim_create_autocmd("CursorHold", { vim.api.nvim_create_autocmd("CursorHold", {
buffer=bufnr, buffer=bufnr,
callback = function() callback = function()
local float_opts = { local opts = {
focusable = false, focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = 'rounded', border = 'rounded',
@ -36,11 +36,11 @@ local custom_attach = function(client, bufnr)
vim.b.diagnostics_pos = { nil, nil } vim.b.diagnostics_pos = { nil, nil }
end end
local cursor_pos = api.nvim_win_get_cursor(0) local cursor_pos = vim.api.nvim_win_get_cursor(0)
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) and if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) and
#vim.diagnostic.get() > 0 #vim.diagnostic.get() > 0
then then
vim.diagnostic.open_float(nil, float_opts) vim.diagnostic.open_float(nil, opts)
end end
vim.b.diagnostics_pos = cursor_pos vim.b.diagnostics_pos = cursor_pos
@ -148,27 +148,36 @@ if utils.executable('bash-language-server') then
}) })
end end
if utils.executable("lua-language-server") then local sumneko_binary_path = fn.exepath("lua-language-server")
-- settings for lua-language-server can be found on https://github.com/sumneko/lua-language-server/wiki/Settings . if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
local sumneko_root_path = fn.fnamemodify(sumneko_binary_path, ":h:h:h")
local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
lspconfig.sumneko_lua.setup({ lspconfig.sumneko_lua.setup({
on_attach = custom_attach, on_attach = custom_attach,
cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" },
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT", version = "LuaJIT",
-- Setup your lua path
path = runtime_path,
}, },
diagnostics = { diagnostics = {
-- Get the language server to recognize the `vim` global -- Get the language server to recognize the `vim` global
globals = { "vim" }, globals = { "vim" },
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files, -- Make the server aware of Neovim runtime files
-- see also https://github.com/sumneko/lua-language-server/wiki/Libraries#link-to-workspace . library = api.nvim_get_runtime_file("", true),
-- Lua-dev.nvim also has similar settings for sumneko lua, https://github.com/folke/lua-dev.nvim/blob/main/lua/lua-dev/sumneko.lua . },
library = { fn.stdpath('data') .. "/site/pack/packer/opt/emmylua-nvim" }, -- Do not send telemetry data containing a randomized but unique identifier
maxPreload = 2000, telemetry = {
preloadFileSize = 50000, enable = false,
}, },
}, },
}, },

View File

@ -355,8 +355,6 @@ packer.startup({
} }
use { 'ii14/emmylua-nvim', ft = 'lua' } use { 'ii14/emmylua-nvim', ft = 'lua' }
use { 'j-hui/fidget.nvim', after = 'nvim-lspconfig', config = [[require('config.fidget-nvim')]]}
end, end,
config = { config = {
max_jobs = 16, max_jobs = 16,

View File

@ -1,7 +1,7 @@
local fn = vim.fn local fn = vim.fn
-- inspect something -- inspect something
function _G.inspect(item) function inspect(item)
vim.pretty_print(item) vim.pretty_print(item)
end end