This commit is contained in:
Fabian Becker
2025-09-04 17:01:42 +02:00
parent bbece9eade
commit c30a121b99
12 changed files with 110 additions and 385 deletions

View File

@@ -1,129 +0,0 @@
if vim.g.vscode then
return
end
local Worktree = require("git-worktree")
local Job = require("plenary.job")
local FTerm = require("FTerm")
local function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local function schedule_notify(message, level)
vim.schedule(function()
vim.notify.notify(message, level or "info")
end)
end
local function is_elixir_project()
return file_exists(vim.loop.cwd() .. "/" .. "mix.exs")
end
-- Run mix compile
local compile_job = Job:new({
command = "mix",
args = { "compile" },
on_start = function()
schedule_notify("Compiling...", "debug")
end,
on_exit = function(_j, _return_val)
schedule_notify("Compiling done")
end
})
-- Run mix deps.get
local deps_job = Job:new({
command = "mix",
args = { "deps.get" },
on_start = function()
schedule_notify("Fetching dependencies...")
end,
on_exit = function(_j, _return_val)
schedule_notify("Fetched dependencies")
end
})
local function create_docker_up_job(path)
return Job:new({
command = "docker-compose",
args = { "up" },
cwd = path,
detached = true,
on_start = function ()
schedule_notify("Running docker in " .. path, "debug")
end,
on_exit = function (_j, return_val)
if return_val ~= 0 then
schedule_notify("Error running docker for " .. path, "error")
end
end
})
end
local function create_docker_down_job(path)
return Job:new({
command = "docker-compose",
args = { "down" },
cwd = path,
on_start = function ()
schedule_notify("Shutting down containers at " .. path, "debug")
end,
on_exit = function ()
schedule_notify("Shut down containers at " .. path, "debug")
end,
})
end
local iex = FTerm:new({
cmd = { "iex", "-S", "mix" },
dimensions = {
height = 0.9,
width = 0.9
}
})
vim.keymap.set('t', '<A-t>', function ()
iex:toggle()
end)
vim.keymap.set('n', '<A-t>', function ()
iex:toggle()
end)
Worktree.on_tree_change(function(op, metadata)
if op == Worktree.Operations.Create and is_elixir_project() then
deps_job:and_then(compile_job)
deps_job:start()
end
if op == Worktree.Operations.Switch and is_elixir_project() then
local docker_down = create_docker_down_job(metadata.prev_path)
local docker_up = create_docker_up_job(metadata.path)
docker_down:and_then(docker_up)
compile_job:start()
docker_down:start()
iex:close(true)
end
end)
local group = vim.api.nvim_create_augroup('MyCustomNeogitEvents', { clear = true })
vim.api.nvim_create_autocmd('User', {
pattern = 'NeogitPullComplete',
group = group,
callback = function ()
deps_job:and_then(compile_job)
deps_job:start()
end,
})
vim.api.nvim_create_autocmd('User', {
pattern = 'NeogitBranchCheckout',
group = group,
callback = function ()
deps_job:and_then(compile_job)
deps_job:start()
end,
})

View File

@@ -1,39 +0,0 @@
if vim.g.vscode then
return
end
local nnoremap = require('halfdan.keymap').nnoremap
local actions = require("telescope.actions")
local action_state = require "telescope.actions.state"
local worktree = require("git-worktree")
local function create_workspace_for_issue()
require'telescope'.extensions.jira.live_search({
attach_mappings =function ()
actions.select_default:replace(
function ()
local selection = action_state.get_selected_entry()
local branch_name = "fb/" .. selection.key:lower()
vim.schedule(function ()
-- Create worktree
worktree.create_worktree(branch_name, branch_name, "origin")
end)
end
)
return true
end,
assignee = "fbecker@adobe.com",
})
end
nnoremap("<leader>jw", function ()
create_workspace_for_issue()
end)
nnoremap("<leader>js", function ()
require'telescope'.extensions.jira.live_search({
project="BES"
})
end)

View File

@@ -83,13 +83,6 @@ vim.lsp.protocol.CompletionItemKind = {
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>Lspsaga show_line_diagnostics<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true })
-- LSP settings
local lsp_status = require('lsp-status')
lsp_status.register_progress()
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
@@ -149,94 +142,54 @@ local on_attach = function(client, bufnr)
lsp_status.on_attach(client, bufnr)
end
local function config(_config)
_config = vim.tbl_deep_extend("force", {
log_level = vim.lsp.protocol.MessageType.Log,
message_level = vim.lsp.protocol.MessageType.Log,
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = on_attach,
}, _config or {})
-- Set default client capabilities plus window/workDoneProgress
_config.capabilities = vim.tbl_extend('keep', _config.capabilities or {}, lsp_status.capabilities)
return _config
end
-- Enable the following language servers
-- local servers = { 'gopls', 'julials', 'rust_analyzer', 'pyright' }
-- for _, lsp in ipairs(servers) do
-- lspconfig[lsp].setup(config())
-- end
require'lspconfig'.lua_ls.setup {
vim.lsp.config("lua_ls", {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Tell the language server which version of Lua you're using
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'},
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
-- Do not send telemetry data containing a randomized but unique identifier
enable = false,
},
},
},
}
require('rust-tools').setup({
tools = {
runnables = {
use_telescope = true,
},
inlay_hints = {
auto = true,
parameter_hints_prefix = "",
other_hints_prefix = "",
}
},
server = {
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
},
},
},
})
-- Enable it
vim.lsp.enable("lua_ls")
local lexical_config = {
filetypes = { "elixir", "eelixir", "heex" },
cmd = { "/Users/fbecker/code/lexical/_build/dev/package/lexical/bin/start_lexical.sh" },
settings = {},
}
if not configs.lexical then
configs.lexical = {
default_config = {
filetypes = lexical_config.filetypes,
cmd = lexical_config.cmd,
root_dir = function(fname)
return lspconfig.util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir()
end,
-- optional settings
settings = lexical_config.settings,
vim.lsp.config('gopls', {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_markers = { "go.work", "go.mod", ".git" },
settings = {
gopls = {
analyses = {
unusedparams = true,
shadow = true,
},
staticcheck = true,
},
}
end
},
})
lspconfig.lexical.setup({})
vim.lsp.enable 'gopls'
lspconfig.gleam.setup({})
vim.lsp.config('expert', {
cmd = { 'expert' },
root_markers = { 'mix.exs', '.git' },
filetypes = { 'elixir', 'eelixir', 'heex' },
})
vim.lsp.enable 'expert'
vim.lsp.enable 'gleam'

View File

@@ -1,16 +0,0 @@
if vim.g.vscode then
return
end
local ok, nls = pcall(require, 'null-ls')
if not ok then
return
end
nls.setup({
sources = {
nls.builtins.formatting.stylua,
nls.builtins.diagnostics.credo,
},
})

View File

@@ -37,12 +37,6 @@ nnoremap("<leader>vh", function()
builtin.help_tags()
end)
nnoremap("<leader>wc", function()
require('telescope').extensions.git_worktree.create_git_worktree()
end)
nnoremap("<leader>ws", function()
require('telescope').extensions.git_worktree.git_worktrees()
end)
nnoremap("<leader>gc", function()
builtin.git_branches()
end)