Setup the directory structure to handle both mac and linux, and stowing with only one command, well two, one for the OS specific dir as well.

This commit is contained in:
Martin Larsson 2024-04-19 01:19:38 +02:00
parent 5759f6a798
commit bc87253453
65 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,44 @@
local utils = require("lspconfig.util")
return {
default_config = {
cmd = { "bash-language-server", "start" },
settings = {
bashIde = {
-- Glob pattern for finding and parsing shell script files in the workspace.
-- Used by the background analysis features across files.
-- Prevent recursive scanning which will cause issues when opening a file
-- directly in the home directory (e.g. ~/foo.sh).
--
-- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
globPattern = vim.env.GLOB_PATTERN or "**/*@(.sh|.inc|.bash|.command|.zsh|zshrc|zsh_*)",
},
bash = {
format = {
enable = true,
shell = "shfmt",
args = {
"-i",
"4",
"-bn",
"-ci"
}
},
ignorePatterns = {
"node_modules",
".git"
},
lint = {
enable = true
},
trace = {
server = "verbose"
},
},
},
filetypes = { "sh", "zsh" },
root_dir = utils.find_git_ancestor,
single_file_support = true,
},
}

View file

@ -0,0 +1,54 @@
local function switch_between_header_and_source(bufnr)
local util = require("lspconfig/util")
bufnr = util.validate_bufnr(bufnr)
local clangd_client = util.get_active_client_by_name(bufnr, "clangd")
local params = { uri = vim.uri_from_bufnr(bufnr) }
-- invert this with an early return
if not clangd_client then
print "method textDocument/switchSourceHeader is not supported by any servers active on the current buffer"
return
end
clangd_client.request("textDocument/switchSourceHeader", params, function(err, result)
if err then
error(tostring(err))
end
if not result then
print("Corresponding file cannot be determined")
return
end
vim.api.nvim_command("drop " .. vim.uri_to_fname(result))
end, bufnr)
end
local M = {
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--completion-style=bundled",
-- "--cross-file-rename", // This has been deprecated
"--rename-file-limit=0",
"--header-insertion=iwyu",
"--inlay-hints",
"--compile-commands-dir=build/",
},
commands = {
ClangdSwitchSourceHeader = {
function()
switch_between_header_and_source(0)
end,
description = "Switch between source/header",
},
},
}
function M.post_setup()
require("utils").add_keymaps({
n = {
["<leader>ko"] = { cmd = ":ClangdSwitchSourceHeader<CR>" }
},
})
end
return M

View file

@ -0,0 +1,3 @@
return {
}

View file

@ -0,0 +1,30 @@
return {
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
},
},
})
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end
}

View file

@ -0,0 +1 @@
return {}