diff --git a/config/neovim/after/ftplugin/term.vim b/config/neovim/after/ftplugin/term.vim deleted file mode 100644 index 16bbc95..0000000 --- a/config/neovim/after/ftplugin/term.vim +++ /dev/null @@ -1,4 +0,0 @@ -setlocal norelativenumber -setlocal nonumber - -setlocal scrolloff=0 diff --git a/config/neovim/after/plugin/colorscheme.lua b/config/neovim/after/plugin/colorscheme.lua deleted file mode 100644 index a6f0ace..0000000 --- a/config/neovim/after/plugin/colorscheme.lua +++ /dev/null @@ -1,21 +0,0 @@ -local status_ok, catppuccin = pcall(require, "catppuccin") -if not status_ok then - return -end - -catppuccin.setup { - flavour = "macchiato", - integrations = { - cmp = true, - gitsigns = true, - native_lsp = { - enabled = true, - }, - telescope = true, - treesitter = true, - }, - term_colors = true, - transparent_background = true, -} - -vim.cmd.colorscheme "catppuccin" diff --git a/config/neovim/after/plugin/comment.lua b/config/neovim/after/plugin/comment.lua deleted file mode 100644 index eb350eb..0000000 --- a/config/neovim/after/plugin/comment.lua +++ /dev/null @@ -1,19 +0,0 @@ -local status_ok, comment = pcall(require, "Comment") -if not status_ok then - return -end - -comment.setup { - padding = true, - - opleader = { - line = "gc", - block = "gb", - }, - - mappings = { - basic = true, - extra = true, - extended = false, - }, -} diff --git a/config/neovim/after/plugin/completion.lua b/config/neovim/after/plugin/completion.lua deleted file mode 100644 index 0e60829..0000000 --- a/config/neovim/after/plugin/completion.lua +++ /dev/null @@ -1,82 +0,0 @@ -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then - return -end - -local snip_status_ok, luasnip = pcall(require, "luasnip") -if not snip_status_ok then - return -end - -vim.opt.shortmess:append "c" - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.config.disable, - }, - - sources = { - { name = "nvim_lsp_signature_help" }, - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "cmp_tabnine" }, - { name = "path" }, - { name = "luasnip" }, - { name = "buffer", keyword_length = 5, max_item_count = 5 }, - }, - - sorting = { - comparators = { - cmp.config.compare.offset, - cmp.config.compare.exact, - cmp.config.compare.score, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - - formatting = { - format = require("lspkind").cmp_format { - with_text = true, - menu = { - buffer = "[buf]", - cmp_tabnine = "[tn]", - luasnip = "[snip]", - nvim_lsp = "[lsp]", - nvim_lua = "[lua]", - path = "[path]", - }, - }, - }, - - experimental = { - ghost_text = true, - native_menu = false, - }, -} - -cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, -}) - -vim.cmd [[ - augroup DadbodSql - au! - autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } } - augroup END -]] diff --git a/config/neovim/after/plugin/conform.lua b/config/neovim/after/plugin/conform.lua deleted file mode 100644 index 6c47234..0000000 --- a/config/neovim/after/plugin/conform.lua +++ /dev/null @@ -1,11 +0,0 @@ -local conform = require "conform" - -conform.setup { - formatters_by_ft = { - rst = { "rstfmt" }, - }, -} - -conform.formatters.rstfmt = { - command = "rstfmt"; -} diff --git a/config/neovim/after/plugin/dap.lua b/config/neovim/after/plugin/dap.lua deleted file mode 100644 index 53a241b..0000000 --- a/config/neovim/after/plugin/dap.lua +++ /dev/null @@ -1,74 +0,0 @@ -local has_dap, dap = pcall(require, "dap") -if not has_dap then - return -end - -local has_dap_ui, dapui = pcall(require, "dapui") -if not has_dap_ui then - return -end - -dap.adapters.php = { - type = "executable", - command = "node", - args = { os.getenv "HOME" .. "/build/vscode-php-debug/out/phpDebug.js" }, -} - -dap.configurations.php = { - { - type = "php", - request = "launch", - name = "Listen for Xdebug", - port = 9003, - pathMappings = { - ["/var/www/html"] = "${workspaceFolder}", - }, - }, -} - -dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() -end - -dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() -end - -dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() -end - -require("dapui").setup { - layouts = { - { - elements = { - { id = "scopes", size = 0.25 }, - "breakpoints", - "stacks", - "watches", - }, - size = 40, -- 40 columns - position = "right", - }, - { - elements = { - "repl", - "console", - }, - size = 0.25, -- 25% of total lines - position = "bottom", - }, - }, -} - -require("nvim-dap-virtual-text").setup { - commented = true, -} - -local nmap = require("opdavies.keymap").nmap - -nmap { "", ":lua require'dap'.step_over()" } -nmap { "", ":lua require'dap'.step_into()" } -nmap { "", ":lua require'dap'.step_over()" } -nmap { "", ":lua require'dap'.continue()" } -nmap { "b", ":lua require'dap'.toggle_breakpoint()" } diff --git a/config/neovim/after/plugin/dial.lua b/config/neovim/after/plugin/dial.lua deleted file mode 100644 index 8e051a8..0000000 --- a/config/neovim/after/plugin/dial.lua +++ /dev/null @@ -1,52 +0,0 @@ -local status_ok, dial_config = pcall(require, "dial.config") -if not status_ok then - return -end - -local augend = require "dial.augend" - -dial_config.augends:register_group { - visual = { - augend.integer.alias.decimal, - augend.integer.alias.hex, - augend.date.alias["%Y/%m/%d"], - augend.constant.alias.alpha, - augend.constant.alias.Alpha, - }, - - mygroup = { - augend.constant.new { - elements = { "TRUE", "FALSE" }, - word = true, - cyclic = true, - }, - - augend.constant.new { - elements = { "public", "protected", "private" }, - word = true, - cyclic = true, - }, - - augend.constant.new { - elements = { "&&", "||" }, - word = false, - cyclic = true, - }, - - augend.date.alias["%d/%m/%Y"], - augend.constant.alias.bool, -- boolean value (true <-> false) - augend.integer.alias.decimal, - augend.integer.alias.hex, - augend.semver.alias.semver, - }, -} - -local dial_map = require "dial.map" - -local nmap = require("opdavies.keymap").nmap -local vmap = require("opdavies.keymap").vmap - -nmap { "", dial_map.inc_normal "mygroup" } -nmap { "", dial_map.dec_normal "mygroup" } -vmap { "", dial_map.inc_normal "visual" } -vmap { "", dial_map.dec_normal "visual" } diff --git a/config/neovim/after/plugin/fugitive.lua b/config/neovim/after/plugin/fugitive.lua deleted file mode 100644 index 18df603..0000000 --- a/config/neovim/after/plugin/fugitive.lua +++ /dev/null @@ -1,23 +0,0 @@ -vim.keymap.set("n", "gc", "Git commitK") -vim.keymap.set("n", "gs", "GitK") - -vim.api.nvim_create_autocmd("BufWinEnter", { - pattern = "*", - - callback = function() - if vim.bo.ft ~= "fugitive" then - return - end - - local bufnr = vim.api.nvim_get_current_buf() - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "p", function() - vim.cmd.Git "push" - end, opts) - - vim.keymap.set("n", "P", function() - vim.cmd.Git { "pull", "--rebase" } - end, opts) - end, -}) diff --git a/config/neovim/after/plugin/gitsigns.lua b/config/neovim/after/plugin/gitsigns.lua deleted file mode 100644 index 8f0570e..0000000 --- a/config/neovim/after/plugin/gitsigns.lua +++ /dev/null @@ -1,40 +0,0 @@ -local gitsigns_status_ok, gitsigns = pcall(require, "gitsigns") -if not gitsigns_status_ok then - return -end - -gitsigns.setup { - linehl = false, - numhl = true, -} - -local bufnr = vim.api.nvim_get_current_buf() - -local map = require("opdavies.keymap").map -local nmap = require("opdavies.keymap").nmap -local vmap = require("opdavies.keymap").vmap - -nmap { "[h", "Gitsigns prev_hunk" } -nmap { "]h", "Gitsigns next_hunk" } - -nmap { "hR", gitsigns.reset_buffer } -nmap { "hS", gitsigns.stage_buffer } -nmap { "hp", gitsigns.preview_hunk } -nmap { "hr", gitsigns.reset_hunk } -nmap { "hs", gitsigns.stage_hunk } -nmap { "hu", gitsigns.undo_stage_hunk } -vmap { - "hr", - function() - gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" } - end, -} -vmap { - "hs", - function() - gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" } - end, -} - --- Text object. -map { { "o", "x" }, "ih", ":Gitsigns select_hunk" } diff --git a/config/neovim/after/plugin/harpoon.lua b/config/neovim/after/plugin/harpoon.lua deleted file mode 100644 index 8d2c7d9..0000000 --- a/config/neovim/after/plugin/harpoon.lua +++ /dev/null @@ -1,18 +0,0 @@ -require("harpoon").setup() - -local nmap = require("opdavies.keymap").nmap - -nmap { "", require("harpoon.ui").toggle_quick_menu } -nmap { "", require("harpoon.mark").add_file } - -nmap { "hl", require("harpoon.ui").toggle_quick_menu } -nmap { "hm", require("harpoon.mark").add_file } - -for i = 1, 5 do - nmap { - string.format("%s", i), - function() - require("harpoon.ui").nav_file(i) - end, - } -end diff --git a/config/neovim/after/plugin/lualine.lua b/config/neovim/after/plugin/lualine.lua deleted file mode 100644 index 7c0d419..0000000 --- a/config/neovim/after/plugin/lualine.lua +++ /dev/null @@ -1,9 +0,0 @@ -require("lualine").setup { - options = { - component_separators = { left = "", right = "" }, - extensions = { "fzf", "quickfix" }, - icons_enabled = false, - section_separators = { left = "", right = "" }, - theme = "catppuccin", - }, -} diff --git a/config/neovim/after/plugin/luasnip.lua b/config/neovim/after/plugin/luasnip.lua deleted file mode 100644 index 8b86e47..0000000 --- a/config/neovim/after/plugin/luasnip.lua +++ /dev/null @@ -1,97 +0,0 @@ -if not pcall(require, "luasnip") then - return -end - -local api = vim.api -local fn = vim.fn - -local ls = require "luasnip" - -local snippet = ls.snippet -local t = ls.text_node - -local shortcut = function(val) - if type(val) == "string" then - return { t { val }, i(0) } - end - - if type(val) == "table" then - for k, v in ipairs(val) do - if type(v) == "string" then - val[k] = t { v } - end - end - end - - return val -end - -local make = function(tbl) - local result = {} - for k, v in pairs(tbl) do - table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v)))) - end - - return result -end - -local snippets = {} - -for _, ft_path in ipairs(api.nvim_get_runtime_file("lua/opdavies/snippets/ft/*.lua", true)) do - local ft = fn.fnamemodify(ft_path, ":t:r") - snippets[ft] = make(loadfile(ft_path)()) - - ls.add_snippets(ft, snippets[ft]) -end - -ls.add_snippets("js", snippets.javascript) -ls.add_snippets("typescript", snippets.javascript) -ls.add_snippets("vue", snippets.javascript) - -require("luasnip.loaders.from_vscode").lazy_load() - -ls.config.set_config { - enable_autosnippets = true, - history = true, - updateevents = "TextChanged,TextChangedI", -} - -local imap = require("opdavies.keymap").imap -local map = require("opdavies.keymap").map -local nmap = require("opdavies.keymap").nmap - --- Expand the current item or just to the next item within the snippet. -map { - { "i", "s" }, - "", - function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end - end, - { silent = true }, -} - --- Jump backwards. -map { - { "i", "s" }, - "", - function() - if ls.jumpable(-1) then - ls.jump(-1) - end - end, - { silent = true }, -} - --- Select within a list of options. -imap { - "", - function() - if ls.choice_active() then - ls.change_choice(1) - end - end, -} - -nmap { "s", "source ~/Code/github.com/opdavies/dotfiles/config/neovim/after/plugin/luasnip.lua" } diff --git a/config/neovim/after/plugin/netrw.lua b/config/neovim/after/plugin/netrw.lua deleted file mode 100644 index 1feb376..0000000 --- a/config/neovim/after/plugin/netrw.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.keymap.set("n", "pv", vim.cmd.Ex) - -vim.g.netrw_banner = 0 -vim.g.netrw_browse_split = 0 -vim.g.netrw_liststyle = 3 -vim.g.netrw_winsize = 20 diff --git a/config/neovim/after/plugin/nvim-rest.lua b/config/neovim/after/plugin/nvim-rest.lua deleted file mode 100644 index 857a433..0000000 --- a/config/neovim/after/plugin/nvim-rest.lua +++ /dev/null @@ -1,12 +0,0 @@ -local status_ok, rest_nvim = pcall(require, "rest-nvim") -if not status_ok then - return -end - -rest_nvim.setup() - -local nmap = require("opdavies.keymap").nmap - -nmap { "rr", "RestNvim" } -nmap { "rp", "RestNvimPreview" } -nmap { "rl", "RestNvimLast" } diff --git a/config/neovim/after/plugin/phpactor.lua b/config/neovim/after/plugin/phpactor.lua deleted file mode 100644 index 2d0f249..0000000 --- a/config/neovim/after/plugin/phpactor.lua +++ /dev/null @@ -1,4 +0,0 @@ -local nmap = require("opdavies.keymap").nmap - -nmap { "pm", ":PhpactorContextMenu" } -nmap { "pn", ":PhpactorClassNew" } diff --git a/config/neovim/after/plugin/projectionist.lua b/config/neovim/after/plugin/projectionist.lua deleted file mode 100644 index 81467bb..0000000 --- a/config/neovim/after/plugin/projectionist.lua +++ /dev/null @@ -1,58 +0,0 @@ -local heuristics = { - ["composer.json"] = { - ["src/*.php"] = { - type = "source", - alternate = "tests/{}Test.php", - }, - - ["src/Controller/*.php"] = { - type = "controller", - }, - - ["src/Model/*.php"] = { - type = "model", - }, - - ["src/Service/*.php"] = { - type = "service", - }, - - ["tests/*Test.php"] = { - type = "test", - alternate = "src/{}.php", - }, - }, - - ["fractal.config.js"] = { - ["*.config.yml"] = { - alternate = "{dirname}/{basename}.twig", - }, - - ["*.twig"] = { - alternate = "{dirname}/{basename}.config.yml", - }, - }, - - ["package.json"] = { - ["src/*.ts"] = { - type = "source", - alternate = "tests/{}.test.ts", - }, - - ["src/*.service.ts"] = { - type = "source", - alternate = "tests/{}.test.ts", - }, - - ["tests/*.test.ts"] = { - type = "test", - alternate = "src/{}.ts", - }, - }, -} - -vim.g.projectionist_heuristics = heuristics - -local nmap = require("opdavies.keymap").nmap - -nmap { "aa", "A" } diff --git a/config/neovim/after/plugin/refactoring.lua b/config/neovim/after/plugin/refactoring.lua deleted file mode 100644 index 2eb0658..0000000 --- a/config/neovim/after/plugin/refactoring.lua +++ /dev/null @@ -1,18 +0,0 @@ -local status_ok, refactoring = pcall(require, "refactoring") -if not status_ok then - return -end - -local nmap = require("opdavies.keymap").nmap -local vmap = require("opdavies.keymap").vmap - --- TODO: add keymaps - https://github.com/ThePrimeagen/refactoring.nvim#configuration-for-refactoring-operations -refactoring.setup {} - -local opts = { silent = true } - -nmap { "ri", "lua require 'refactoring'.refactor 'Inline Variable'", opts } - -vmap { "re", "lua require 'refactoring'.refactor 'Extract Function'", opts } -vmap { "ri", "lua require 'refactoring'.refactor 'Inline Variable'", opts } -vmap { "rv", "lua require 'refactoring'.refactor 'Extract Variable'", opts } diff --git a/config/neovim/after/plugin/treesitter.lua b/config/neovim/after/plugin/treesitter.lua deleted file mode 100644 index 59007af..0000000 --- a/config/neovim/after/plugin/treesitter.lua +++ /dev/null @@ -1,137 +0,0 @@ -local configs = require "nvim-treesitter.configs" -local context = require "treesitter-context" -local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move" - -local map = require("opdavies.keymap").map -local nmap = require("opdavies.keymap").nmap - -configs.setup { - autotag = { - enable = true, - }, - - context_commenting = { - enable = true, - }, - - highlight = { - enable = true, - }, - - indent = { - disable = { "yaml" }, - enable = true, - }, - - matchup = { - enable = true, - }, - - textobjects = { - select = { - enable = true, - lookahead = true, - - keymaps = { - ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, - ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, - ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, - ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, - - ["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" }, - ["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" }, - ["l:"] = { query = "@property.lhs", desc = "Select left part of an object property" }, - ["r:"] = { query = "@property.rhs", desc = "Select right part of an object property" }, - - ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, - ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, - - ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, - ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, - - ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, - ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, - - ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, - ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, - - ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, - ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, - - ["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" }, - ["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" }, - }, - }, - }, - - swap = { - enable = true, - - swap_next = { - ["na"] = "@parameter.inner", -- swap parameters/argument with next - ["n:"] = "@property.outer", -- swap object property with next - ["nm"] = "@function.outer", -- swap function with next - }, - - swap_previous = { - ["pa"] = "@parameter.inner", -- swap parameters/argument with prev - ["p:"] = "@property.outer", -- swap object property with prev - ["pm"] = "@function.outer", -- swap function with previous - }, - }, - - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - - goto_next_start = { - ["]f"] = { query = "@call.outer", desc = "Next function call start" }, - ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, - ["]c"] = { query = "@class.outer", desc = "Next class start" }, - ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, - ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, - - ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, - ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, - }, - - goto_next_end = { - ["]F"] = { query = "@call.outer", desc = "Next function call end" }, - ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, - ["]C"] = { query = "@class.outer", desc = "Next class end" }, - ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, - ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, - }, - - goto_previous_start = { - ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, - ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, - ["[c"] = { query = "@class.outer", desc = "Prev class start" }, - ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" }, - ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, - }, - - goto_previous_end = { - ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, - ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, - ["[C"] = { query = "@class.outer", desc = "Prev class end" }, - ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" }, - ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, - }, - }, -} - -nmap { "th", "TSHighlightCapturesUnderCursor" } -nmap { "tp", "TSPlaygroundToggle" } - --- vim way: ; goes to the direction you were moving. -map {{ "n", "o", "x" }, ";", ts_repeat_move.repeat_last_move} -map {{ "n", "o", "x" }, ",", ts_repeat_move.repeat_last_move_opposite} - --- Optionally, make builtin f, F, t, T also repeatable with ; and , -map {{ "n", "o", "x" }, "f", ts_repeat_move.builtin_f} -map {{ "n", "o", "x" }, "F", ts_repeat_move.builtin_F} -map {{ "n", "o", "x" }, "t", ts_repeat_move.builtin_t} -map {{ "n", "o", "x" }, "T", ts_repeat_move.builtin_T} - -context.setup { enable = true } diff --git a/config/neovim/after/plugin/undotree.lua b/config/neovim/after/plugin/undotree.lua deleted file mode 100644 index 5bc27b4..0000000 --- a/config/neovim/after/plugin/undotree.lua +++ /dev/null @@ -1,3 +0,0 @@ -local nmap = require("opdavies.keymap").nmap - -nmap { "u", vim.cmd.UndotreeToggle } diff --git a/config/neovim/after/plugin/vim-test.lua b/config/neovim/after/plugin/vim-test.lua deleted file mode 100644 index fd38419..0000000 --- a/config/neovim/after/plugin/vim-test.lua +++ /dev/null @@ -1,20 +0,0 @@ -local map = vim.api.nvim_set_keymap - -local options = { - silent = true, -} - -map("n", "tf", ":TestFile", options) -map("n", "tg", ":TestVisit", options) -map("n", "tl", ":TestLast", options) -map("n", "tn", ":TestNearest", options) -map("n", "ts", ":TestSuite", options) - -vim.cmd [[ - let test#echo_command = 0 - let test#neovim#start_normal = 1 - let test#strategy = "neoterm" - - let test#php#phpunit#executable = 'run test' - let test#php#phpunit#options = '--colors=always --testdox' -]] diff --git a/config/neovim/autoload/opdavies.vim b/config/neovim/autoload/opdavies.vim deleted file mode 100644 index 449666b..0000000 --- a/config/neovim/autoload/opdavies.vim +++ /dev/null @@ -1,12 +0,0 @@ -if !exists('*opdavies#save_and_exec') - function! opdavies#save_and_exec() abort - if &filetype == 'vim' - :silent! write - :source % - elseif &filetype == 'lua' - :silent! write - :luafile % - endif - return - endfunction -endif diff --git a/config/neovim/lua/opdavies/globals.lua b/config/neovim/lua/opdavies/globals.lua deleted file mode 100644 index d6fd70c..0000000 --- a/config/neovim/lua/opdavies/globals.lua +++ /dev/null @@ -1,13 +0,0 @@ -P = function(v) - print(vim.inspect(v)) - return v -end - -RELOAD = function(...) - return require("plenary.reload").reload_module(...) -end - -R = function(name) - RELOAD(name) - return require(name) -end diff --git a/config/neovim/lua/opdavies/init.lua b/config/neovim/lua/opdavies/init.lua deleted file mode 100644 index 386cced..0000000 --- a/config/neovim/lua/opdavies/init.lua +++ /dev/null @@ -1,22 +0,0 @@ -pcall("require", impatient) - -require "opdavies.globals" - -require("opdavies.options").setup() - -require "opdavies.lsp" - -require "opdavies.telescope.setup" -require "opdavies.telescope.mappings" - -vim.api.nvim_create_user_command("GoToFile", function() - require("opdavies.telescope").git_files() -end, {}) - -local imap = require("opdavies.keymap").imap -local nmap = require("opdavies.keymap").nmap -local xmap = require("opdavies.keymap").xmap - --- Quicker macro playback. -nmap { "Q", "@qj" } -xmap { "Q", ":norm @q" } diff --git a/config/neovim/lua/opdavies/keymap.lua b/config/neovim/lua/opdavies/keymap.lua deleted file mode 100644 index df7d5f3..0000000 --- a/config/neovim/lua/opdavies/keymap.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} - -M.imap = function(tbl) - vim.keymap.set("i", tbl[1], tbl[2], tbl[3]) -end - -M.map = function(tbl) - vim.keymap.set(tbl[1], tbl[2], tbl[3], tbl[4] or {}) -end - -M.nmap = function(tbl) - vim.keymap.set("n", tbl[1], tbl[2], tbl[3]) -end - -M.vmap = function(tbl) - vim.keymap.set("v", tbl[1], tbl[2], tbl[3]) -end - -M.xmap = function(tbl) - vim.keymap.set("x", tbl[1], tbl[2], tbl[3]) -end - -return M diff --git a/config/neovim/lua/opdavies/lsp/init.lua b/config/neovim/lua/opdavies/lsp/init.lua deleted file mode 100644 index 170777b..0000000 --- a/config/neovim/lua/opdavies/lsp/init.lua +++ /dev/null @@ -1,153 +0,0 @@ -local has_lsp, lspconfig = pcall(require, "lspconfig") -if not has_lsp then - return -end - -local nvim_status = require "lsp-status" - -local imap = require("opdavies.keymap").imap -local nmap = require("opdavies.keymap").nmap - -local telescope_mapper = require "opdavies.telescope.mappings" - -local buf_nnoremap = function(opts) - opts.buffer = 0 - nmap(opts) -end - -local buf_inoremap = function(opts) - opts.buffer = 0 - imap(opts) -end - -local default_capabilities = vim.lsp.protocol.make_client_capabilities() -default_capabilities = require("cmp_nvim_lsp").default_capabilities(default_capabilities) - -local custom_init = function(client) - client.config.flags = client.config.flags or {} - client.config.flags.allow_incremental_sync = true -end - -local custom_attach = function(client) - local filetype = vim.api.nvim_buf_get_option(0, "filetype") - - nvim_status.on_attach(client) - - buf_inoremap { "", vim.lsp.buf.signature_help } - buf_nnoremap { "ca", vim.lsp.buf.code_action } - buf_nnoremap { "d", vim.diagnostic.open_float } - buf_nnoremap { "rn", vim.lsp.buf.rename } - buf_nnoremap { "rr", "LspRestart" } - buf_nnoremap { "[d", vim.diagnostic.goto_prev } - buf_nnoremap { "]d", vim.diagnostic.goto_next } - buf_nnoremap { "gD", vim.lsp.buf.declaration } - buf_nnoremap { "gd", vim.lsp.buf.definition } - buf_nnoremap { "gi", vim.lsp.buf.implementation } - buf_nnoremap { "gT", vim.lsp.buf.type_definition } - - if filetype ~= "lua" then - buf_nnoremap { "K", vim.lsp.buf.hover } - end - - telescope_mapper("dl", "diagnostics", nil, true) - - -- Set autocommands conditional on server_capabilities - if client.server_capabilities.document_highlight then - vim.cmd [[ - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]] - end - - -- Attach any filetype specific options to the client - -- filetype_attach[filetype](client) -end - -local servers = { - ansiblels = true, - astro = true, - bashls = true, - cssls = true, - gopls = true, - html = true, - rnix = true, - terraformls = true, - tsserver = true, - vuels = true, - - intelephense = { - filetypes = { "php", "module", "test", "inc" }, - }, - - lua_ls = { - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - }, - }, - }, - - tailwindcss = { - filetypes = { "html", "html.twig", "javascript", "typescript", "vue" }, - init_options = { - userLanguages = { - ["html.twig"] = "html", - }, - }, - }, - - yamlls = { - settings = { - yaml = { - keyOrdering = false, - }, - }, - }, -} - -local setup_server = function(server, config) - if not config then - return - end - - if type(config) ~= "table" then - config = {} - end - - config = vim.tbl_deep_extend("force", { - on_init = custom_init, - on_attach = custom_attach, - capabilities = default_capabilities, - flags = { - debounce_text_changes = nil, - }, - }, config) - - lspconfig[server].setup(config) -end - -for server, config in pairs(servers) do - setup_server(server, config) -end - -vim.diagnostic.config { - float = { - source = true, - }, - signs = true, - underline = false, - update_in_insert = false, - virtual_text = { spacing = 2 }, -} - -vim.keymap.set("n", "f", function() - vim.lsp.buf.format { async = true } -end) - -require "opdavies.lsp.none-ls" -require "opdavies.lsp.signature" diff --git a/config/neovim/lua/opdavies/lsp/none-ls.lua b/config/neovim/lua/opdavies/lsp/none-ls.lua deleted file mode 100644 index 706eaf6..0000000 --- a/config/neovim/lua/opdavies/lsp/none-ls.lua +++ /dev/null @@ -1,46 +0,0 @@ -local status_ok, null_ls = pcall(require, "null-ls") -if not status_ok then - return -end - -local code_actions = null_ls.builtins.code_actions -local diagnostics = null_ls.builtins.diagnostics -local formatting = null_ls.builtins.formatting - -null_ls.setup { - sources = { - code_actions.gitsigns, - - formatting.black, - formatting.markdownlint, - formatting.phpcbf.with { - command = "./vendor/bin/phpcbf", - condition = function(utils) - return utils.root_has_file { "phpcs.xml.dist" } - end, - }, - formatting.prettier, - formatting.rustywind, - formatting.stylua, - - diagnostics.eslint.with { - condition = function(utils) - return utils.root_has_file { ".eslintrc.js" } - end, - }, - diagnostics.markdownlint.with { - extra_args = { "--config", "~/.markdownlint.yaml" }, - }, - diagnostics.php, - diagnostics.phpcs.with { - command = "./vendor/bin/phpcs", - condition = function(utils) - return utils.root_has_file { "phpcs.xml.dist" } - end, - }, - diagnostics.phpstan, - diagnostics.shellcheck, - }, - - temp_dir = "/tmp", -} diff --git a/config/neovim/lua/opdavies/lsp/signature.lua b/config/neovim/lua/opdavies/lsp/signature.lua deleted file mode 100644 index 365c973..0000000 --- a/config/neovim/lua/opdavies/lsp/signature.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status_ok, lsp_signature = pcall(require, "lsp_signature") -if not status_ok then - return -end - -lsp_signature.setup {} diff --git a/config/neovim/lua/opdavies/options.lua b/config/neovim/lua/opdavies/options.lua deleted file mode 100644 index 74ee5a1..0000000 --- a/config/neovim/lua/opdavies/options.lua +++ /dev/null @@ -1,181 +0,0 @@ -local M = {} - -local function set_autocmd() - vim.cmd [[ - autocmd BufRead,BufNewFile *.test set filetype=php - - autocmd FileType gitcommit highlight ColorColumn ctermbg=8 - autocmd FileType gitcommit setlocal colorcolumn=50,72 - autocmd FileType gitcommit setlocal spell - autocmd FileType gitcommit setlocal textwidth=72 - ]] - - -- Cursorline highlighting control. - -- Only have it on in the current buffer. - local group = vim.api.nvim_create_augroup("CursorLineControl", { clear = true }) - local set_cursorline = function(event, value, pattern) - vim.api.nvim_create_autocmd(event, { - group = group, - pattern = pattern, - callback = function() - vim.opt_local.cursorline = value - end, - }) - end - set_cursorline("WinLeave", false) - set_cursorline("WinEnter", true) - set_cursorline("FileType", false, "TelescopePrompt") - - vim.api.nvim_create_autocmd("TermOpen", { - callback = function() - vim.cmd.set "filetype=term" - end, - }) -end - -local function set_filetypes() - vim.cmd [[ - filetype indent on - filetype on - filetype plugin on - ]] -end - -local function set_key_mappings() - local map = vim.api.nvim_set_keymap - - local options = { noremap = true } - - map("n", "so", ":call opdavies#save_and_exec()", options) - - -- Format paragraphs to an 80 character line length. - map("n", "g", "gqap", options) - map("x", "g", "gqa", options) - - -- Make the current file executable - map("n", "x", ":!chmod +x %", options) - - -- Yank from the current column to the end of the line - map("n", "Y", "yg$", options) - - -- Keep things centred - map("n", "n", "nzzzv", options) - map("n", "N", "Nzzzv", options) - - -- Remove arrow keys - map("v", "", "", options) - map("v", "", "", options) - map("v", "", "", options) - map("v", "", "", options) - - -- Clears hlsearch after doing a search, otherwise just does normal stuff - vim.cmd [[ nnoremap {-> v:hlsearch ? ":nohl\" : "\"}() ]] - - map("n", "", ":silent !tmux neww tmux-sessioniser", { noremap = true, silent = true }) - - local keymap = require "opdavies.keymap" - local imap = keymap.imap - local nmap = keymap.nmap - local vmap = keymap.vmap - local xmap = keymap.xmap - - -- Easy insertion of a trailing ; or , from insert mode - imap { ",,", "A," } - imap { ";;", "A;" } - - nmap { "ga", "(EasyAlign)" } - xmap { "ga", "(EasyAlign)" } - - -- Focus on the current buffer. - nmap { "-", ":wincmd _:wincmd |", { noremap = true, silent = true } } - - -- Automatically resize buffers. - nmap { "=", ":wincmd =", { noremap = true, silent = true } } - - -- Move line(s) up and down. - local opts = { noremap = true, silent = true } - imap { "", ":m .+1==gi", opts } - imap { "", ":m .-2==gi", opts } - nmap { "", ":m .+1==", opts } - nmap { "", ":m .-2==", opts } - vmap { "", ":m '>+1gv=gv", opts } - vmap { "", ":m '<-2gv=gv", opts } - - -- Move half a screen up or down and re-center. - nmap { "", "zz" } - nmap { "", "zz" } -end - -local function set_highlights() - vim.cmd [[highlight Comment cterm=italic gui=italic]] -end - -local function set_vim_g() - vim.g.mapleader = " " -end - -local function set_vim_o() - local settings = { - autoindent = true, - backup = false, - breakindent = true, - conceallevel = 0, - cursorline = true, - expandtab = true, - foldlevel = 1, - foldlevelstart = 99, - foldmethod = "indent", - formatoptions = "lm", - hidden = false, - inccommand = "split", - linebreak = true, - list = true, - mouse = "n", - number = true, - pumblend = 10, - pumheight = 10, - relativenumber = true, - scrolloff = 10, - shiftwidth = 2, - showmode = false, - signcolumn = "yes:1", - smartindent = true, - softtabstop = 2, - splitbelow = false, - splitright = true, - swapfile = false, - syntax = "on", - tabstop = 2, - termguicolors = true, - textwidth = 0, - undodir = os.getenv("HOME") .. "/.vim/undodir", - undofile = true, - updatetime = 1000, - wrap = false, - } - - for key, value in pairs(settings) do - vim.o[key] = value - end - - vim.opt.backupdir:remove "." -- keep backups out of the current directory - vim.opt.clipboard:append "unnamedplus" - vim.opt.listchars:append { - trail = "ยท", - } - vim.opt.completeopt = { "menu", "menuone", "noselect" } - vim.opt.laststatus = 3 -end - -M.setup = function() - set_vim_g() - set_vim_o() - set_key_mappings() - set_autocmd() - set_filetypes() - set_highlights() - - vim.g.snippets = "luasnip" -end - -return M diff --git a/config/neovim/lua/opdavies/snippets/ft/javascript.lua b/config/neovim/lua/opdavies/snippets/ft/javascript.lua deleted file mode 100644 index d3e795f..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/javascript.lua +++ /dev/null @@ -1,10 +0,0 @@ -local fmta = require("luasnip.extras.fmt").fmta -local ls = require "luasnip" - -local i = ls.insert_node - -local M = { - log = fmta("console.log(<>);", { i(1, "value") }), -} - -return M diff --git a/config/neovim/lua/opdavies/snippets/ft/lua.lua b/config/neovim/lua/opdavies/snippets/ft/lua.lua deleted file mode 100644 index c2abfba..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/lua.lua +++ /dev/null @@ -1,27 +0,0 @@ -local ls = require "luasnip" - -local fmt = require("luasnip.extras.fmt").fmt -local rep = require("luasnip.extras").rep - -local f, i = ls.function_node, ls.insert_node - -return { - pcall = fmt( - [[ - local status_ok, {} = pcall(require, "{}") - if not status_ok then - return - end - ]], - { i(1), rep(1) } - ), - - req = fmt([[local {} = require "{}"]], { - f(function(import_name) - local parts = vim.split(import_name[1][1], ".", true) - - return parts[#parts] or "" - end, { 1 }), - i(1), - }), -} diff --git a/config/neovim/lua/opdavies/snippets/ft/markdown.lua b/config/neovim/lua/opdavies/snippets/ft/markdown.lua deleted file mode 100644 index b2a76e4..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/markdown.lua +++ /dev/null @@ -1,20 +0,0 @@ -local fmt = require("luasnip.extras.fmt").fmt -local ls = require "luasnip" - -local i = ls.insert_node - -local M = { - frontmatter = fmt( - [[ - --- - title: {} - --- - {} - ]], - { i(1), i(0) } - ), - - link = fmt([[[{}]({}){} ]], { i(1), i(2), i(0) }), -} - -return M diff --git a/config/neovim/lua/opdavies/snippets/ft/nix.lua b/config/neovim/lua/opdavies/snippets/ft/nix.lua deleted file mode 100644 index 1ef44d5..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/nix.lua +++ /dev/null @@ -1,23 +0,0 @@ -local fmta = require("luasnip.extras.fmt").fmta -local ls = require "luasnip" - -local c = ls.choice_node -local i = ls.insert_node -local t = ls.text_node - -local M = { - vimplugin = fmta( - [[ - { - plugin = <>.<>; - type = "lua"; - config = '' - <> - ''; - }<> - ]], - { c(1, { t "vimPlugins", t "customVim" }), i(2), i(3), i(0) } - ), -} - -return M diff --git a/config/neovim/lua/opdavies/snippets/ft/php.lua b/config/neovim/lua/opdavies/snippets/ft/php.lua deleted file mode 100644 index 75e4e53..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/php.lua +++ /dev/null @@ -1,61 +0,0 @@ -local fmta = require("luasnip.extras.fmt").fmta -local ls = require "luasnip" - -local c = ls.choice_node -local f = ls.function_node -local i = ls.insert_node -local t = ls.text_node - -local M = { - __construct = fmta( - [[ - public function __construct(<>) { - <> - } - ]], - { i(1), i(0) } - ), - - __invoke = fmta( - [[ - public function __invoke(<>) { - <> - } - ]], - { i(1), i(0) } - ), - - func = fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) }), - - met = fmta( - [[ - <> function <>(<>)<> { - <> - }<> - ]], - { c(1, { t "public", t "protected", t "private" }), i(2), i(3), i(4), i(5), i(0) } - ), - - pest = fmta("<>('<>', function() {\n <>\n});", { c(1, { t "it", t "test" }), i(2), i(0) }), - - test = fmta( - [[ - public function test<>(): void { - <> - }<> - ]], - { i(1), i(2), i(0) } - ), - - testa = fmta( - [[ - /** @test */ - public function <>(): void { - <> - }<> - ]], - { i(1), i(2), i(0) } - ), -} - -return M diff --git a/config/neovim/lua/opdavies/snippets/ft/rst.lua b/config/neovim/lua/opdavies/snippets/ft/rst.lua deleted file mode 100644 index 206bbf1..0000000 --- a/config/neovim/lua/opdavies/snippets/ft/rst.lua +++ /dev/null @@ -1,49 +0,0 @@ -local fmta = require("luasnip.extras.fmt").fmta -local ls = require "luasnip" - -local i = ls.insert_node -local f = ls.function_node - -local fill_line = function(char) - return function() - local row = vim.api.nvim_win_get_cursor(0)[1] - local lines = vim.api.nvim_buf_get_lines(0, row - 2, row, false) - return string.rep(char, #lines[1]) - end -end - -local M = { - class = { ".. class:: ", i(1) }, - footer = { ".. footer:: ", i(1) }, - link = { ".. _", i(1), ":" }, - raw = { ".. raw:: ", i(1) }, - - -- TODO: add an optional new line and ":width" property. - image = { ".. image:: ", i(1) }, - - head = f(fill_line "=", {}), - sub = f(fill_line "-", {}), - subsub = f(fill_line "^", {}), - - -- Add a page break with an optional page template. - pb = fmta( - [[ - .. raw:: pdf - - PageBreak<> - ]], - { i(0) } - ), - - -- Add a new speaker note. - ta = fmta( - [[ - .. raw:: pdf - - TextAnnotation "<>" - ]], - { i(0) } - ), -} - -return M diff --git a/config/neovim/lua/opdavies/telescope/init.lua b/config/neovim/lua/opdavies/telescope/init.lua deleted file mode 100644 index 56ccc24..0000000 --- a/config/neovim/lua/opdavies/telescope/init.lua +++ /dev/null @@ -1,161 +0,0 @@ -SHOULD_RELOAD_TELESCOPE = true - -local reloader = function() - if SHOULD_RELOAD_TELESCOPE then - RELOAD "plenary" - RELOAD "telescope" - RELOAD "opdavies.telescope.setup" - end -end - -local themes = require "telescope.themes" - -local M = {} - -function M.current_buf() - local opts = { - sorting_strategy = "ascending", - previewer = false, - } - - require("telescope.builtin").current_buffer_fuzzy_find(opts) -end - -M.diagnostics = function() - local theme = require("telescope.themes").get_dropdown { - previewer = false, - } - - require("telescope.builtin").diagnostics(theme) -end - -function M.lsp_document_symbols() - local theme = require("telescope.themes").get_dropdown { - previewer = false, - } - - require("telescope.builtin").lsp_document_symbols(theme) -end - -function M.edit_neovim() - local opts = { - cwd = "~/Code/github.com/opdavies/dotfiles/config/neovim", - find_command = { "rg", "--no-ignore", "--files", "--follow" }, - path_display = { "shorten" }, - prompt_title = "~ dotfiles ~", - no_ignore = true, - - layout_strategy = "flex", - layout_config = { - height = 0.8, - prompt_position = "top", - width = 0.9, - - horizontal = { - width = { padding = 0.15 }, - }, - vertical = { - preview_height = 0.75, - }, - }, - } - - require("telescope.builtin").find_files(opts) -end - -function M.edit_zsh() - local opts = { - cwd = "~/.config/zsh", - path_display = { "shorten" }, - prompt_title = "~ zsh ~", - no_ignore = true, - - layout_strategy = "flex", - layout_config = { - height = 0.8, - prompt_position = "top", - width = 0.9, - - horizontal = { - width = { padding = 0.15 }, - }, - vertical = { - preview_height = 0.75, - }, - }, - } - - require("telescope.builtin").find_files(opts) -end - -function M.file_browser() - local opts = { - cwd = vim.fn.expand "%:p:h", - sorting_strategy = "ascending", - } - - require("telescope").extensions.file_browser.file_browser(opts) -end - -function M.find_files() - local opts = { - file_ignore_patterns = { ".git/", "**/{core,contrib}", "vendor" }, - } - - require("telescope.builtin").find_files(opts) -end - -function M.find_all_files() - local opts = { - no_ignore = true, - prompt_title = "All Files", - } - - require("telescope.builtin").find_files(opts) -end - -function M.git_files() - local opts = { - file_ignore_patterns = { ".git/", "**/{core,contrib}", "vendor" }, - hidden = true, - no_ignore = true, - } - - require("telescope.builtin").git_files(opts) -end - -function M.grep_prompt() - require("telescope.builtin").grep_string { - path_display = { "shorten" }, - search = vim.fn.input "Grep String > ", - } -end - -function M.live_grep() - require("telescope").extensions.live_grep_args.live_grep_args { - file_ignore_patterns = { ".git/" }, - hidden = true, - no_ignore = true, - sorting_strategy = "ascending", - } -end - -function M.oldfiles() - local opts = { - prompt_title = "History", - } - - require("telescope").extensions.frecency.frecency(opts) -end - -return setmetatable({}, { - __index = function(_, k) - reloader() - - if M[k] then - return M[k] - else - return require("telescope.builtin")[k] - end - end, -}) diff --git a/config/neovim/lua/opdavies/telescope/mappings.lua b/config/neovim/lua/opdavies/telescope/mappings.lua deleted file mode 100644 index 7daf876..0000000 --- a/config/neovim/lua/opdavies/telescope/mappings.lua +++ /dev/null @@ -1,62 +0,0 @@ -TelescopeMapArgs = TelescopeMapArgs or {} - -local telescope = require "telescope" - -local telescope_mapper = function(key, f, options, buffer) - local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true) - - TelescopeMapArgs[map_key] = options or {} - - local mode = "n" - local rhs = string.format("lua R('opdavies.telescope')['%s'](TelescopeMapArgs['%s'])", f, map_key) - - local map_options = { - noremap = true, - silent = true, - } - - if not buffer then - vim.api.nvim_set_keymap(mode, key, rhs, map_options) - else - vim.api.nvim_buf_set_keymap(0, mode, key, rhs, map_options) - end -end - -telescope_mapper("fb", "buffers") -telescope_mapper("fd", "find_files") -telescope_mapper("fD", "find_all_files") -telescope_mapper("fe", "file_browser") -telescope_mapper("ff", "current_buf") -telescope_mapper("fg", "git_files") -telescope_mapper("fh", "help_tags") -telescope_mapper("fl", "live_grep") -telescope_mapper("fo", "oldfiles") - -local builtin = require "telescope.builtin" -local nmap = require("opdavies.keymap").nmap - -nmap { - "fw", - function() - local word = vim.fn.expand "" - builtin.grep_string { search = word } - end, -} - -nmap { - "fW", - function() - local word = vim.fn.expand "" - builtin.grep_string { search = word } - end, -} - -telescope_mapper("gp", "grep_prompt") - -telescope_mapper("ds", "lsp_document_symbols") -telescope_mapper("dl", "diagnostics") - -telescope_mapper("en", "edit_neovim") -telescope_mapper("ez", "edit_zsh") - -return telescope_mapper diff --git a/config/neovim/lua/opdavies/telescope/setup.lua b/config/neovim/lua/opdavies/telescope/setup.lua deleted file mode 100644 index 53090b4..0000000 --- a/config/neovim/lua/opdavies/telescope/setup.lua +++ /dev/null @@ -1,101 +0,0 @@ -local status_ok, telescope = pcall(require, "telescope") -if not status_ok then - return -end - -local Job = require "plenary.job" -local previewers = require "telescope.previewers" - --- Create a new maker that won't preview binary files --- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries -local new_maker = function(filepath, bufnr, opts) - filepath = vim.fn.expand(filepath) - Job:new({ - command = "file", - args = { "--mime-type", "-b", filepath }, - on_exit = function(j) - local mime_type = vim.split(j:result()[1], "/")[1] - if mime_type == "text" then - previewers.buffer_previewer_maker(filepath, bufnr, opts) - else - vim.schedule(function() - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" }) - end) - end - end, - }):sync() -end - -local action_layout = require "telescope.actions.layout" -local actions = require "telescope.actions" -local lga_actions = require "telescope-live-grep-args.actions" - -telescope.setup { - defaults = { - buffer_previewer_maker = new_maker, - file_ignore_patterns = { ".direnv/", ".git/" }, - layout_config = { - prompt_position = "top", - }, - - preview = { - hide_on_startup = true, - }, - - mappings = { - i = { - [""] = actions.delete_buffer, - [""] = actions.which_key, - [""] = action_layout.toggle_preview, - [""] = action_layout.toggle_mirror, - }, - }, - - no_ignore = true, - path_display = { truncate = 1 }, - prompt_prefix = "$ ", - sorting_strategy = "ascending", - }, - - pickers = { - find_files = { - hidden = true, - }, - - buffers = { - previewer = false, - layout_config = { - width = 80, - }, - }, - - lsp_references = { - previewer = false, - }, - }, - - extensions = { - file_browser = { - theme = "ivy", - }, - - live_grep_args = { - auto_quoting = true, - mappings = { - i = { - [""] = lga_actions.quote_prompt {}, - [""] = lga_actions.quote_prompt { postfix = " --iglob " }, - }, - }, - }, - - ["ui-select"] = { - require("telescope.themes").get_dropdown {}, - }, - }, -} - -telescope.load_extension "file_browser" -telescope.load_extension "fzf" -telescope.load_extension "refactoring" -telescope.load_extension "ui-select" diff --git a/flake.lock b/flake.lock index 43dc422..4f37500 100644 --- a/flake.lock +++ b/flake.lock @@ -17,6 +17,23 @@ "type": "indirect" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1704982712, + "narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "07f6395285469419cf9d078f59b5b49993198c00", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -24,11 +41,11 @@ ] }, "locked": { - "lastModified": 1705535278, - "narHash": "sha256-V5+XKfNbiY0bLKLQlH+AXyhHttEL7XcZBH9iSbxxexA=", + "lastModified": 1706080884, + "narHash": "sha256-qhxisCrSraN5YWVb0lNCFH8ovqnCw5W9ldac4Dzr0Nw=", "owner": "nix-community", "repo": "home-manager", - "rev": "b84191db127c16a92cbdf7f7b9969d58bb456699", + "rev": "6b28ab2d798c1c84e24053d95f4ee1dd9d81e2fb", "type": "github" }, "original": { @@ -39,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1705316053, - "narHash": "sha256-J2Ey5mPFT8gdfL2XC0JTZvKaBw/b2pnyudEXFvl+dQM=", + "lastModified": 1705856552, + "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c3e128f3c0ecc1fb04aef9f72b3dcc2f6cecf370", + "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", "type": "github" }, "original": { @@ -55,11 +72,11 @@ }, "nixpkgs-2311": { "locked": { - "lastModified": 1705331948, - "narHash": "sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4=", + "lastModified": 1705916986, + "narHash": "sha256-iBpfltu6QvN4xMpen6jGGEb6jOqmmVQKUrXdOJ32u8w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b8dd8be3c790215716e7c12b247f45ca525867e2", + "rev": "d7f206b723e42edb09d9d753020a84b3061a79d8", "type": "github" }, "original": { @@ -87,12 +104,52 @@ "type": "github" } }, + "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1703961334, + "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "opdavies-nvim": { + "inputs": { + "flake-parts": "flake-parts_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706088444, + "narHash": "sha256-SUkQwotWRMOHk8U2AKcSRA1Jt7EEvodKUb5t/WApLOs=", + "owner": "opdavies", + "repo": "opdavies.nvim", + "rev": "fd32fb48877dfbef088af4dd706bb3993b56c750", + "type": "github" + }, + "original": { + "owner": "opdavies", + "repo": "opdavies.nvim", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", "home-manager": "home-manager", "nixpkgs": "nixpkgs", - "nixpkgs-2311": "nixpkgs-2311" + "nixpkgs-2311": "nixpkgs-2311", + "opdavies-nvim": "opdavies-nvim" } } }, diff --git a/flake.nix b/flake.nix index 0222070..aca8eda 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,8 @@ home-manager.url = "github:nix-community/home-manager"; nixpkgs-2311.url = "github:nixos/nixpkgs/nixos-23.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + opdavies-nvim.inputs.nixpkgs.follows = "nixpkgs"; + opdavies-nvim.url = "github:opdavies/opdavies.nvim"; }; outputs = inputs@{ flake-parts, self, ... }: @@ -20,13 +22,6 @@ systems = [ "x86_64-linux" ]; perSystem = { pkgs, self', ... }: { - packages = { - opdavies-nvim = pkgs.vimUtils.buildVimPlugin { - name = "opdavies-nvim"; - src = ./config/neovim; - }; - }; - formatter = pkgs.nixpkgs-fmt; }; diff --git a/system/shared/modules/neovim.nix b/system/shared/modules/neovim.nix index 6436f7c..a9e697d 100644 --- a/system/shared/modules/neovim.nix +++ b/system/shared/modules/neovim.nix @@ -202,7 +202,7 @@ in # Themes vimPlugins.catppuccin-nvim - inputs.self.packages.${pkgs.system}.opdavies-nvim + inputs.opdavies-nvim.packages.${pkgs.system}.default ]; extraLuaConfig = ''