mirror of
				https://github.com/halfdan/dotfiles.git
				synced 2025-10-31 12:36:12 +00:00 
			
		
		
		
	Soooo many changes
This commit is contained in:
		| @@ -1,23 +1,26 @@ | ||||
| env: | ||||
|   TERM: screen-256color | ||||
|  | ||||
| # Font | ||||
| font: | ||||
|   normal: | ||||
|     family: Hack Nerd Font | ||||
|     family: FiraCode Nerd Font Mono | ||||
|     style: Regular | ||||
|  | ||||
|   bold: | ||||
|     family: Hack Nerd Font | ||||
|     family: FiraCode Nerd Font Mono | ||||
|     style: Bold | ||||
|  | ||||
|   italic: | ||||
|     family: Hack Nerd Font | ||||
|     family: FiraCode Nerd Font Mono | ||||
|     style: Italic | ||||
|  | ||||
|   bold_italic: | ||||
|     family: Hack Nerd Font | ||||
|     family: FiraCode Nerd Font Mono | ||||
|     style: Bold Italic | ||||
|  | ||||
|   size: 15 | ||||
|   ligatures: true | ||||
|   size: 18 | ||||
|   ligatures: true  | ||||
|  | ||||
| # Gruvbox | ||||
| colors: | ||||
| @@ -54,5 +57,6 @@ window: | ||||
| key_bindings: | ||||
|   - { key: Right, mods: Alt, chars: "\x1BF" } | ||||
|   - { key: Left,  mods: Alt, chars: "\x1BB" } | ||||
|   - { key: Key6,        mods: Control, chars: "\x1e"                     } | ||||
|  | ||||
| alt_send_esc: true | ||||
|   | ||||
| @@ -1,46 +1,116 @@ | ||||
| local Worktree = require("git-worktree") | ||||
| local Job = require("plenary.job") | ||||
| local FTerm = require("FTerm") | ||||
|  | ||||
| local function schedule_notify(message) | ||||
| 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) | ||||
|     vim.notify.notify(message, level or "info") | ||||
|   end) | ||||
| end | ||||
|  | ||||
| local function is_massdriver() | ||||
|   return not not (string.find(vim.loop.cwd(), "massdriver.git", 1, true)) | ||||
| 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) | ||||
|   local compile_job = Job:new({ | ||||
|     command = "mix", | ||||
|     args = { "compile" }, | ||||
|     on_start = function() | ||||
|       schedule_notify("Compiling...") | ||||
|     end, | ||||
|     on_exit = function(_j, _return_val) | ||||
|       schedule_notify("Compiling done") | ||||
|     end | ||||
|   }) | ||||
|  | ||||
|   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 | ||||
|   }) | ||||
|  | ||||
|   if op == Worktree.Operations.Create and is_massdriver() then | ||||
|   if op == Worktree.Operations.Create and is_elixir_project() then | ||||
|     deps_job:and_then(compile_job) | ||||
|     deps_job:sync() | ||||
|     compile_job:wait() | ||||
|     deps_job:start() | ||||
|   end | ||||
|  | ||||
|   if op == Worktree.Operations.Switch and is_massdriver() then | ||||
|   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, | ||||
| }) | ||||
|   | ||||
| @@ -127,7 +127,7 @@ local on_attach = function(client, bufnr) | ||||
|   nnoremap("gr", function() vim.lsp.buf.references() end) | ||||
|   nnoremap("<leader>rn", function() vim.lsp.buf.rename() end) | ||||
|   nnoremap("<leader>cl", function() vim.lsp.codelens.run() end) | ||||
|   nnoremap("<leader>ff", function() vim.lsp.buf.format{async = true} end) | ||||
|   nnoremap("<leader>fa", function() vim.lsp.buf.format{async = true} end) | ||||
|   inoremap("<C-h>", function() vim.lsp.buf.signature_help() end) | ||||
|  | ||||
|   lsp_status.on_attach(client, bufnr) | ||||
| @@ -137,7 +137,7 @@ 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").update_capabilities(vim.lsp.protocol.make_client_capabilities()), | ||||
|     capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), | ||||
|     on_attach = on_attach, | ||||
|   }, _config or {}) | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								.config/nvim/after/plugin/luasnip.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.config/nvim/after/plugin/luasnip.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| require("luasnip/loaders/from_vscode").lazy_load() | ||||
| @@ -2,25 +2,24 @@ local Remap = require("halfdan.keymap") | ||||
| local nnoremap = Remap.nnoremap | ||||
| local builtin = require("telescope.builtin") | ||||
|  | ||||
| nnoremap("<leader>pg", function() | ||||
| nnoremap("<leader>gg", function() | ||||
|   builtin.live_grep() | ||||
| end) | ||||
| nnoremap("<C-p>", function() | ||||
|   if not pcall(builtin.git_files) then | ||||
|     builtin.find_files() | ||||
|   end | ||||
|   builtin.commands() | ||||
| end) | ||||
| nnoremap("<Leader>pf", function() | ||||
|  | ||||
| nnoremap("<Leader>ff", function() | ||||
|   builtin.find_files() | ||||
| end) | ||||
|  | ||||
| nnoremap("<Leader>ps", function() | ||||
| nnoremap("<Leader>fs", function() | ||||
|   builtin.lsp_workspace_symbols() | ||||
| end) | ||||
| nnoremap("<leader>pw", function() | ||||
| nnoremap("<leader>gw", function() | ||||
|   builtin.grep_string { search = vim.fn.expand("<cword>") } | ||||
| end) | ||||
| nnoremap("<leader>pb", function() | ||||
| nnoremap("<leader>fb", function() | ||||
|   builtin.buffers() | ||||
| end) | ||||
| nnoremap("<leader>vh", function() | ||||
| @@ -36,3 +35,5 @@ end) | ||||
| nnoremap("<leader>gc", function() | ||||
|   builtin.git_branches() | ||||
| end) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -5,10 +5,9 @@ local source_mapping = { | ||||
|   buffer = "[Buffer]", | ||||
|   nvim_lsp = "[LSP]", | ||||
|   nvim_lua = "[Lua]", | ||||
|   cmp_tabnine = "[TN]", | ||||
|   path = "[Path]", | ||||
|   orgmode = "[Org]", | ||||
|   luasnip = "[Snippet]", | ||||
|   jira = "[Jira]", | ||||
| } | ||||
|  | ||||
| local has_words_before = function() | ||||
| @@ -58,38 +57,27 @@ cmp.setup({ | ||||
|     end, { "i", "s" }) | ||||
|   }, | ||||
|   sources = cmp.config.sources({ | ||||
|     { name = 'cmp_tabnine' }, | ||||
|     { name = 'nvim_lsp' }, | ||||
|     { name = 'luasnip' }, | ||||
|     { name = 'nvim_lsp' }, | ||||
|   }, { | ||||
|     { name = 'buffer'} | ||||
|   }), | ||||
|   formatting = { | ||||
|     format = function(entry, vim_item) | ||||
|       vim_item.kind = lspkind.presets.default[vim_item.kind] | ||||
|       local menu = source_mapping[entry.source.name] | ||||
|       if entry.source.name == 'cmp_tabnine' then | ||||
|         if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then | ||||
|           menu = entry.completion_item.data.detail .. ' ' .. menu | ||||
|         end | ||||
|         vim_item.kind = '?' | ||||
|       end | ||||
|       vim_item.menu = menu | ||||
|       return vim_item | ||||
|     end | ||||
|   }, | ||||
|   experimental = { | ||||
|     ghost_text = true, | ||||
|   } | ||||
| }) | ||||
|  | ||||
| -- Set configuration for specific filetype. | ||||
| cmp.setup.filetype('org', { | ||||
|   sources = cmp.config.sources({ | ||||
|     { name = 'orgmode' }, | ||||
|     { name = 'cmp_tabnine' }, | ||||
|   }, { | ||||
|       { name = 'buffer' }, | ||||
|     }) | ||||
| }) | ||||
|  | ||||
| -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). | ||||
| cmp.setup.cmdline('/', { | ||||
| cmp.setup.cmdline({ '/', '?' }, { | ||||
|   sources = { | ||||
|     { name = 'buffer' } | ||||
|   } | ||||
| @@ -105,17 +93,3 @@ cmp.setup.cmdline(':', { | ||||
|   mappings = cmp.mapping.preset.cmdline(), | ||||
| }) | ||||
|  | ||||
| -- Setup tabnine  | ||||
| local tabnine = require('cmp_tabnine.config') | ||||
| tabnine:setup({ | ||||
|   max_lines = 1000; | ||||
|   max_num_results = 20; | ||||
|   sort = true; | ||||
|   run_on_every_keystroke = true; | ||||
|   snippet_placeholder = '..'; | ||||
|   ignored_file_types = { -- default is not to ignore | ||||
|     -- uncomment to ignore in lua: | ||||
|     lua = true | ||||
|   }; | ||||
| }) | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1,11 @@ | ||||
|  | ||||
| local function formatted_status() | ||||
|   local status = require'lsp-status'.status() | ||||
|   status = string.gsub(status, "%%", "%%%%") | ||||
|   return status | ||||
| end | ||||
|  | ||||
|  | ||||
| require 'lualine'.setup { | ||||
|   options = { | ||||
|     icons_enabled = true, | ||||
| @@ -10,7 +18,12 @@ require 'lualine'.setup { | ||||
|     lualine_a = { 'mode' }, | ||||
|     lualine_b = { 'branch', 'diff', 'diagnostics' }, | ||||
|     lualine_c = { 'filename' }, | ||||
|     lualine_x = { "require'lsp-status'.status()", 'filetype' }, | ||||
|     lualine_x = { | ||||
|       {"require'lsp-status'.status()", fmt = function (str) | ||||
|         return string.gsub(str, "%%", "%%%%") | ||||
|       end}, | ||||
|       'filetype' | ||||
|     }, | ||||
|     lualine_y = { 'progress' }, | ||||
|     lualine_z = { 'location' } | ||||
|   }, | ||||
|   | ||||
| @@ -4,4 +4,3 @@ luasnip.config.set_config { | ||||
|   updateevents = "TextChanged,TextChangedI" | ||||
| } | ||||
|  | ||||
| require("luasnip/loaders/from_vscode").lazy_load() | ||||
|   | ||||
| @@ -9,6 +9,4 @@ neogit.setup { | ||||
|  | ||||
| nnoremap("<leader>gs", function() | ||||
|     neogit.open({ }) | ||||
| end); | ||||
|  | ||||
| nnoremap("<leader>ga", "<cmd>!git fetch --all<CR>"); | ||||
| end) | ||||
|   | ||||
| @@ -30,6 +30,7 @@ end | ||||
|  | ||||
| vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" -- Auto compile when there are changes in plugins.lua | ||||
|  | ||||
| vim.opt.runtimepath:append("~/code/jira.nvim") | ||||
| return require("packer").startup({ | ||||
|   function(use) | ||||
|     -- Packer can manage itself as an optional plugin | ||||
| @@ -113,7 +114,8 @@ return require("packer").startup({ | ||||
|         { 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' }, | ||||
|         { 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' }, | ||||
|         { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp', event = 'CmdlineEnter' }, | ||||
|         {'tzachar/cmp-tabnine', run = './install.sh', after = 'nvim-cmp' } | ||||
|         {'tzachar/cmp-tabnine', run = './install.sh', after = 'nvim-cmp' }, | ||||
|         {'petertriho/cmp-git', after = 'nvim-cmp'}, | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @@ -129,6 +131,8 @@ return require("packer").startup({ | ||||
|         require('Comment').setup() | ||||
|       end | ||||
|     } | ||||
|     use { 'numToStr/FTerm.nvim' } | ||||
|  | ||||
|     -- Telescope fuzzy find files/grep | ||||
|     use {'nvim-lua/popup.nvim'} | ||||
|     use {'nvim-lua/plenary.nvim'} | ||||
|   | ||||
							
								
								
									
										2
									
								
								.config/nvim/syntax/NeogitStatus.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.config/nvim/syntax/NeogitStatus.vim
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| hi def NeogitDiffAddHighlight guibg=#404040 guifg=#859900 | ||||
| hi def NeogitDiffDeleteHighlight guibg=#404040 guifg=#dc322f | ||||
		Reference in New Issue
	
	Block a user