Fix formatting with stylua

pull/2/head
Ensar Sarajčić 2022-04-28 15:53:54 +02:00
parent bb4a89707f
commit e2ffbe8de0
23 changed files with 1101 additions and 1155 deletions

View File

@ -5,7 +5,7 @@ end
-- Allow `require('impatient')` to fail, in case plugins are not yet installed
_ = pcall(require, "impatient")
vim.cmd [[filetype plugin indent on]]
vim.cmd([[filetype plugin indent on]])
vim.api.nvim_exec('let $OVIMHOME = $HOME."/.vim"', false)
vim.api.nvim_exec('let $VIMHOME = $HOME."/.config/nvim"', false)

View File

@ -6,12 +6,12 @@ local M = {}
-- Gets project root directory based on projectionist
function M.get_project_root()
return vim.fn['projectionist#path']()
return vim.fn["projectionist#path"]()
end
-- Get unique project ID based on git repository
function M.get_project_id()
local remote_url = vim.fn['fugitive#RemoteUrl']()
local remote_url = vim.fn["fugitive#RemoteUrl"]()
remote_url = remote_url:gsub("/", ":")
return remote_url
end

View File

@ -15,7 +15,7 @@ local function get_pr_url(...)
-- Remove prefix if it is available, for some of common git services
local common_services = { "github.com", "bitbucket.org", "gitlab.com" }
for k, service in pairs(common_services) do
if (string.find(origin_url, service, 1, true)) then
if string.find(origin_url, service, 1, true) then
-- Common mechanism for managing multiple SSH keys
origin_url = string.gsub(origin_url, "://.*" .. service, "://" .. service)
end
@ -23,7 +23,7 @@ local function get_pr_url(...)
-- This part probably only works on github
local pr_url
if (select("#", ...) == 0) then
if select("#", ...) == 0 then
pr_url = origin_url .. "/compare/" .. vim.fn.FugitiveHead() .. "?expand=1"
else
pr_url = origin_url .. "/compare/" .. select(1, ...) .. "..." .. vim.fn.FugitiveHead() .. "?expand=1"

View File

@ -8,8 +8,7 @@ local download_packer = function()
vim.fn.mkdir(directory, "p")
local out =
vim.fn.system(
local out = vim.fn.system(
string.format("git clone %s %s", "https://github.com/wbthomason/packer.nvim", directory .. "/packer.nvim")
)

View File

@ -1,95 +1,95 @@
return require("packer").startup {
return require("packer").startup({
function(use)
use "wbthomason/packer.nvim"
use("wbthomason/packer.nvim")
-- Tpope general improvements
use "tpope/vim-sensible" -- Sane defaults
use "tpope/vim-endwise" -- Add closing statements automatically for if, function etc
use "tpope/vim-surround" -- Surround with ', ", etc
use "tpope/vim-fugitive" -- Git integration
use "tpope/vim-vinegar" -- Netrw improvements
use "tpope/vim-obsession" -- Session.vim management
use "tpope/vim-dadbod" -- Database access
use "kristijanhusak/vim-dadbod-ui" -- UI For Dadbod
use "tpope/vim-speeddating" -- <C-A> and <C-X> for dates
use "tpope/vim-dispatch" -- Dispatch command
use "tpope/vim-projectionist" -- Project config file!
use "tpope/vim-unimpaired" -- Additional [ and ] mappings
use "tpope/vim-repeat" -- Better . repeat
use "tpope/vim-commentary" -- Commenting motion
use "tpope/vim-sleuth" -- Intendation heuristics
use("tpope/vim-sensible") -- Sane defaults
use("tpope/vim-endwise") -- Add closing statements automatically for if, function etc
use("tpope/vim-surround") -- Surround with ', ", etc
use("tpope/vim-fugitive") -- Git integration
use("tpope/vim-vinegar") -- Netrw improvements
use("tpope/vim-obsession") -- Session.vim management
use("tpope/vim-dadbod") -- Database access
use("kristijanhusak/vim-dadbod-ui") -- UI For Dadbod
use("tpope/vim-speeddating") -- <C-A> and <C-X> for dates
use("tpope/vim-dispatch") -- Dispatch command
use("tpope/vim-projectionist") -- Project config file!
use("tpope/vim-unimpaired") -- Additional [ and ] mappings
use("tpope/vim-repeat") -- Better . repeat
use("tpope/vim-commentary") -- Commenting motion
use("tpope/vim-sleuth") -- Intendation heuristics
-- General improvements
use "lewis6991/gitsigns.nvim" -- Git signs
use "godlygeek/tabular" -- Tabular command for alignment
use "vim-scripts/utl.vim" -- Universal text linking
use {"mbbill/undotree", cmd = "UndotreeToggle"} -- Undos in a tree for easy access
use "mhinz/vim-grepper" -- Grepper command - improved grepping throughout project
use "radenling/vim-dispatch-neovim" -- vim-dispatch for neovim - uses terminal
use "wellle/targets.vim" -- Additional targets for inside and around motions
use "flazz/vim-colorschemes" -- All popular colorschemes
use "romainl/vim-qf" -- Quickfix list upgrades
use "romainl/vim-devdocs" -- Quick DevDocs.io search using :DD
use "gpanders/editorconfig.nvim" -- .editorconfig support
use "lewis6991/impatient.nvim" -- Caching lua modules for faster startup
use("lewis6991/gitsigns.nvim") -- Git signs
use("godlygeek/tabular") -- Tabular command for alignment
use("vim-scripts/utl.vim") -- Universal text linking
use({ "mbbill/undotree", cmd = "UndotreeToggle" }) -- Undos in a tree for easy access
use("mhinz/vim-grepper") -- Grepper command - improved grepping throughout project
use("radenling/vim-dispatch-neovim") -- vim-dispatch for neovim - uses terminal
use("wellle/targets.vim") -- Additional targets for inside and around motions
use("flazz/vim-colorschemes") -- All popular colorschemes
use("romainl/vim-qf") -- Quickfix list upgrades
use("romainl/vim-devdocs") -- Quick DevDocs.io search using :DD
use("gpanders/editorconfig.nvim") -- .editorconfig support
use("lewis6991/impatient.nvim") -- Caching lua modules for faster startup
-- Tools
use "direnv/direnv.vim" -- Integration with Direnv
use "vim-test/vim-test" -- Running tests from vim
use "mfussenegger/nvim-dap" -- Debug Adapter Protocol
use "rcarriga/nvim-dap-ui" -- UI components for DAP
use "theHamsta/nvim-dap-virtual-text" -- Virtual text display for DAP
use "diepm/vim-rest-console" -- REST console for vim
use "jamestthompson3/nvim-remote-containers" -- devcontainer.json support
use "jbyuki/one-small-step-for-vimkind" -- Debugger for Nvim-Lua
use("direnv/direnv.vim") -- Integration with Direnv
use("vim-test/vim-test") -- Running tests from vim
use("mfussenegger/nvim-dap") -- Debug Adapter Protocol
use("rcarriga/nvim-dap-ui") -- UI components for DAP
use("theHamsta/nvim-dap-virtual-text") -- Virtual text display for DAP
use("diepm/vim-rest-console") -- REST console for vim
use("jamestthompson3/nvim-remote-containers") -- devcontainer.json support
use("jbyuki/one-small-step-for-vimkind") -- Debugger for Nvim-Lua
-- Snippets
use "L3MON4D3/LuaSnip" -- snippets support
use "rafamadriz/friendly-snippets" -- Collection of snippets
use "saadparwaiz1/cmp_luasnip" -- cmp snippets support
use("L3MON4D3/LuaSnip") -- snippets support
use("rafamadriz/friendly-snippets") -- Collection of snippets
use("saadparwaiz1/cmp_luasnip") -- cmp snippets support
-- Language support
use "tpope/vim-rails" -- Enables all rails command through vim and integrates with projectionist
use "c-brenn/phoenix.vim" -- Similar to vim-rails, but for phoenix
use "tpope/vim-salve" -- Clojure integration with projectionist
use "tpope/vim-fireplace" -- Clojure REPL and integration
use "vimwiki/vimwiki" -- Vimwiki - personal wiki in vim
use "esensar/vimwiki-reviews-lua" -- Vimwiki extension for periodic reviews
use "ledger/vim-ledger" -- Support for ledger-cli format
use "tandrewnichols/vim-docile" -- Support for vim doc.txt format
use "habamax/vim-godot" -- Godot engine (and script) support
use "guns/vim-sexp" -- Precision editing for S-expressions
use("tpope/vim-rails") -- Enables all rails command through vim and integrates with projectionist
use("c-brenn/phoenix.vim") -- Similar to vim-rails, but for phoenix
use("tpope/vim-salve") -- Clojure integration with projectionist
use("tpope/vim-fireplace") -- Clojure REPL and integration
use("vimwiki/vimwiki") -- Vimwiki - personal wiki in vim
use("esensar/vimwiki-reviews-lua") -- Vimwiki extension for periodic reviews
use("ledger/vim-ledger") -- Support for ledger-cli format
use("tandrewnichols/vim-docile") -- Support for vim doc.txt format
use("habamax/vim-godot") -- Godot engine (and script) support
use("guns/vim-sexp") -- Precision editing for S-expressions
use("tpope/vim-sexp-mappings-for-regular-people") -- Simpler keymaps for vim-sexp
use "tridactyl/vim-tridactyl" -- Tridactyl config file support
use "aklt/plantuml-syntax" -- PlantUML support
use "cdelledonne/vim-cmake" -- CMake integration
use("tridactyl/vim-tridactyl") -- Tridactyl config file support
use("aklt/plantuml-syntax") -- PlantUML support
use("cdelledonne/vim-cmake") -- CMake integration
-- Treesitter
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"} -- Treesitter integration
use "nvim-treesitter/playground" -- TSPlaygroundToggle - access treesitter data
use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) -- Treesitter integration
use("nvim-treesitter/playground") -- TSPlaygroundToggle - access treesitter data
-- LSP
use "neovim/nvim-lspconfig" -- Easy LSP Config
use "alexaandru/nvim-lspupdate" -- Easy install and update for many LSP servers
use "hrsh7th/cmp-nvim-lsp" -- LSP source for cmp
use "hrsh7th/cmp-buffer" -- Buffer source for nvim-cmp
use "hrsh7th/cmp-path" -- Path source for nvim-cmp
use "hrsh7th/cmp-nvim-lua" -- Nvim-Lua source for nvim-cmp
use "hrsh7th/nvim-cmp" -- completion integration
use "nvim-lua/lsp_extensions.nvim" -- LSP extensions (like closing labels for Dart)
use "jose-elias-alvarez/null-ls.nvim" -- Linting and formatting
use("neovim/nvim-lspconfig") -- Easy LSP Config
use("alexaandru/nvim-lspupdate") -- Easy install and update for many LSP servers
use("hrsh7th/cmp-nvim-lsp") -- LSP source for cmp
use("hrsh7th/cmp-buffer") -- Buffer source for nvim-cmp
use("hrsh7th/cmp-path") -- Path source for nvim-cmp
use("hrsh7th/cmp-nvim-lua") -- Nvim-Lua source for nvim-cmp
use("hrsh7th/nvim-cmp") -- completion integration
use("nvim-lua/lsp_extensions.nvim") -- LSP extensions (like closing labels for Dart)
use("jose-elias-alvarez/null-ls.nvim") -- Linting and formatting
-- LSP language specific
use "tjdevries/nlua.nvim" -- Built-in Lua integration with LSP
use "akinsho/flutter-tools.nvim" -- Additional flutter integrations
use "mfussenegger/nvim-jdtls" -- Additional java integrations
use("tjdevries/nlua.nvim") -- Built-in Lua integration with LSP
use("akinsho/flutter-tools.nvim") -- Additional flutter integrations
use("mfussenegger/nvim-jdtls") -- Additional java integrations
-- Lua support
use "nvim-lua/popup.nvim" -- Popup API integration - needed for some plugins
use "nvim-lua/plenary.nvim" -- Lua helpers
use("nvim-lua/popup.nvim") -- Popup API integration - needed for some plugins
use("nvim-lua/plenary.nvim") -- Lua helpers
-- Telescope
use "nvim-telescope/telescope.nvim" -- Fuzzy searcher
use "nvim-telescope/telescope-dap.nvim" -- DAP integration for Telescope
end
}
use("nvim-telescope/telescope.nvim") -- Fuzzy searcher
use("nvim-telescope/telescope-dap.nvim") -- DAP integration for Telescope
end,
})

View File

@ -4,12 +4,14 @@
-- Set completeopt to have a better completion experience
vim.o.completeopt = "menu,menuone,noselect"
local cmp = require "cmp"
local cmp = require("cmp")
local luasnip = require("luasnip")
cmp.setup {
cmp.setup({
snippet = {
expand = function(args) require'luasnip'.lsp_expand(args.body) end
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
@ -44,10 +46,13 @@ cmp.setup {
else
fallback()
end
end, {"i", "s"})
end, { "i", "s" }),
},
sources = {
{name = "nvim_lsp"}, {name = "nvim_lua"}, {name = "path"},
{name = "luasnip"}, {name = "buffer"}
}
}
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer" },
},
})

View File

@ -2,7 +2,7 @@
-- - LSP diagnostics config -
-------------------------------------------------------------------------------
local null_ls = require('null-ls')
local null_ls = require("null-ls")
null_ls.setup({
sources = {
@ -22,7 +22,7 @@ null_ls.setup({
null_ls.builtins.formatting.cmake_format,
-- Lua
null_ls.builtins.formatting.lua_format,
null_ls.builtins.formatting.stylua,
-- Dart
null_ls.builtins.formatting.dart_format,
@ -51,7 +51,7 @@ null_ls.setup({
augroup END
]])
end
end
end,
})
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)

View File

@ -6,15 +6,15 @@ local common_config = require("lsp.server_config")
local M = {}
function M.setup()
require "jdtls".setup_dap()
require "jdtls.setup".add_commands()
require("jdtls").setup_dap()
require("jdtls.setup").add_commands()
local on_attach = function(client, bufnr)
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
common_config.on_attach(client, bufnr)
local code_action_fun = function()
require "jdtls".code_action()
require("jdtls").code_action()
end
vim.keymap.set("n", "<A-CR>", code_action_fun)
vim.keymap.set("n", "<Leader>ac", code_action_fun)
@ -27,9 +27,9 @@ function M.setup()
local workspace_folder = home .. "/.workspace" .. vim.fn.fnamemodify(root_dir, ":p:h:t")
local config = {
flags = {
allow_incremental_sync = true
allow_incremental_sync = true,
},
on_attach = on_attach
on_attach = on_attach,
}
config.settings = {
java = {
@ -37,21 +37,21 @@ function M.setup()
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999
}
}
}
staticStarThreshold = 9999,
},
},
},
}
config.cmd = { "jdtls-start.sh", workspace_folder }
config.on_init = function(client, _)
client.notify("workspace/didChangeConfiguration", { settings = config.settings })
end
local extendedClientCapabilities = require "jdtls".extendedClientCapabilities
local extendedClientCapabilities = require("jdtls").extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
config.init_options = {
-- bundles = bundles;
extendedClientCapabilities = extendedClientCapabilities
extendedClientCapabilities = extendedClientCapabilities,
}
-- Server

View File

@ -9,60 +9,15 @@ M.on_attach = function(client, bufnr)
-- Lsp keymaps
local opts = { buffer = bufnr }
vim.keymap.set(
"n",
"<C-]>",
vim.lsp.buf.definition,
opts
)
vim.keymap.set(
"n",
"gD",
vim.lsp.buf.declaration,
opts
)
vim.keymap.set(
"n",
"gr",
vim.lsp.buf.references,
opts
)
vim.keymap.set(
"n",
"gi",
vim.lsp.buf.implementation,
opts
)
vim.keymap.set(
"n",
"<Leader>rn",
vim.lsp.buf.rename,
opts
)
vim.keymap.set(
"n",
"<C-k>",
vim.lsp.buf.signature_help,
opts
)
vim.keymap.set(
"n",
"K",
vim.lsp.buf.hover,
opts
)
vim.keymap.set(
"n",
"<A-CR>",
vim.lsp.buf.code_action,
opts
)
vim.keymap.set(
"n",
"<Leader>ac",
vim.lsp.buf.code_action,
opts
)
vim.keymap.set("n", "<C-]>", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<A-CR>", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<Leader>ac", vim.lsp.buf.code_action, opts)
end
return M

View File

@ -29,52 +29,49 @@ local servers = {
"vimls",
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
lspconfig[lsp].setup({
on_attach = common_config.on_attach,
capabilities = capabilities
}
capabilities = capabilities,
})
end
lspconfig["gdscript"].setup {
lspconfig["gdscript"].setup({
on_attach = common_config.on_attach,
capabilities = capabilities,
flags = {
-- Slow Godot LS
debounce_text_changes = 600
}
}
debounce_text_changes = 600,
},
})
-- Lua bultin lsp
require("nlua.lsp.nvim").setup(
lspconfig,
{
require("nlua.lsp.nvim").setup(lspconfig, {
on_attach = common_config.on_attach,
capabilities = capabilities,
-- Include globals you want to tell the LSP are real :)
globals = {}
}
)
globals = {},
})
-- Flutter tools
require("flutter-tools").setup {
require("flutter-tools").setup({
lsp = {
on_attach = common_config.on_attach,
capabilities = capabilities
}
}
capabilities = capabilities,
},
})
-- Dotnet LS
local pid = vim.fn.getpid()
local omnisharp_bin = vim.fn.glob("$HOME") .. "/lsp/dotnet/omnisharp/run"
lspconfig.omnisharp.setup {
lspconfig.omnisharp.setup({
cmd = { omnisharp_bin, "--languageserver", "--hostPID", tostring(pid) },
on_attach = common_config.on_attach,
capabilities = capabilities
}
capabilities = capabilities,
})
-- Leminx (XML Language server)
lspconfig.lemminx.setup {
lspconfig.lemminx.setup({
cmd = { "lemminx" },
on_attach = common_config.on_attach,
capabilities = capabilities
}
capabilities = capabilities,
})

View File

@ -18,7 +18,7 @@ end
local function open_rest_console(file)
new_tab_if_needed()
local ending = ".rest"
if file:sub(-(#ending)) ~= ending then
if file:sub(-#ending) ~= ending then
file = file .. ".rest"
end
vim.cmd("e " .. file)
@ -44,22 +44,22 @@ end
-- Opens up a rest console which can be saved -- cached by name
function M.open_cached_rest_console(...)
local name = select(1, ...)
if (select("#", ...) == 0) then
name = require "common.projects".get_project_id()
if select("#", ...) == 0 then
name = require("common.projects").get_project_id()
end
open_cached_rest_console(name)
end
-- Opens up a rest console which can be saved -- cached by name
function M.open_named_cached_rest_console(name)
name = require "common.projects".get_project_id() .. name
name = require("common.projects").get_project_id() .. name
open_cached_rest_console(name)
end
-- Opens up a rest console based on local file path
function M.open_local_rest_console(...)
local file = select(1, ...)
if (select("#", ...) == 0) then
if select("#", ...) == 0 then
file = "default"
end
open_rest_console(file)

View File

@ -22,16 +22,12 @@ function M.get_directory_index(vimwiki_index, directory)
local dir = M.get_vimwiki_subdir(vimwiki_index, directory)
local path = Path:new(dir):expand()
local entries =
scandir.scan_dir(
path,
{
local entries = scandir.scan_dir(path, {
hidden = false,
add_dirs = false,
respect_gitignore = true,
depth = 1
}
)
depth = 1,
})
local index = {}
@ -60,12 +56,12 @@ function M.open_subdirectory_index_file(vimwiki_index, subdirectory)
local lines = {
builder.header(1, subdirectory:sub(1, 1):upper() .. subdirectory:sub(2)),
""
"",
}
-- Add items
for title, fname in pairs(index) do
if (title ~= "index") then
if title ~= "index" then
title = string.gsub(title, "-", " ")
title = title:sub(1, 1):upper() .. title:sub(2)
table.insert(lines, builder.list_item(builder.link(fname, title)))

View File

@ -4,40 +4,21 @@
local dap = require("dap")
vim.api.nvim_create_autocmd(
"FileType",
{
vim.api.nvim_create_autocmd("FileType", {
pattern = "dap-repl",
callback = function(args)
require("dap.ext.autocompl").attach()
end
}
)
end,
})
-- Nvim DAP Treesitter integration
require("nvim-dap-virtual-text").setup()
-- Keymaps
vim.keymap.set(
"n",
"<leader>db",
dap.toggle_breakpoint
)
vim.keymap.set(
"n",
"<leader>dc",
dap.continue
)
vim.keymap.set(
"n",
"<leader>dso",
dap.step_over
)
vim.keymap.set(
"n",
"<leader>dsi",
dap.step_into
)
vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint)
vim.keymap.set("n", "<leader>dc", dap.continue)
vim.keymap.set("n", "<leader>dso", dap.step_over)
vim.keymap.set("n", "<leader>dsi", dap.step_into)
-- Nvim DAP UI
local dapui = require("dapui")
@ -56,13 +37,9 @@ dap.listeners.after["event_initialized"]["me"] = function()
end
end
end
vim.keymap.set(
{"n", "v"},
"K",
function()
vim.keymap.set({ "n", "v" }, "K", function()
dapui.eval()
end
)
end)
end
dap.listeners.after["event_terminated"]["me"] = function()
@ -76,7 +53,7 @@ end
dap.adapters.lldb = {
type = "executable",
command = "lldb-vscode",
name = "lldb"
name = "lldb",
}
dap.configurations.cpp = {
@ -108,7 +85,7 @@ dap.configurations.cpp = {
-- lldb-vscode will receive a `SIGWINCH` signal which can cause problems
-- To avoid that uncomment the following option
-- See https://github.com/mfussenegger/nvim-dap/issues/236#issuecomment-1066306073
postRunCommands = {"process handle -p true -s false -n false SIGWINCH"}
postRunCommands = { "process handle -p true -s false -n false SIGWINCH" },
},
{
name = "Launch with args",
@ -123,14 +100,14 @@ dap.configurations.cpp = {
return vim.split(vim.fn.input("Args: "), " ")
end,
runInTerminal = false,
postRunCommands = {"process handle -p true -s false -n false SIGWINCH"}
postRunCommands = { "process handle -p true -s false -n false SIGWINCH" },
},
{
name = "Attach to process",
type = "lldb",
request = "attach",
pid = require("dap.utils").pick_process,
args = {}
args = {},
},
{
name = "Attach to PID",
@ -139,8 +116,8 @@ dap.configurations.cpp = {
pid = function()
return tonumber(vim.fn.input("PID: "))
end,
args = {}
}
args = {},
},
}
dap.configurations.c = dap.configurations.cpp

View File

@ -2,15 +2,15 @@
-- - Fugitive.vim setup and extra commands -
-------------------------------------------------------------------------------
vim.cmd [[command! -nargs=0 Ggpush :lua require('fugitive_extensions').push_origin()]]
vim.cmd [[command! -nargs=0 Ggpull :lua require('fugitive_extensions').pull_origin()]]
vim.cmd [[command! -nargs=? Gpropen :lua require('fugitive_extensions').open_new_pr(<f-args>)]]
vim.cmd [[command! -nargs=? Gpr Gpropen <args>]]
vim.cmd [[command! -nargs=? Gprprint :lua require('fugitive_extensions').print_pr_url(<f-args>)]]
vim.cmd [[command! -nargs=? Gprcopy :lua require('fugitive_extensions').copy_pr_url(<f-args>)]]
vim.cmd [[command! -nargs=1 Gcbranch :lua require('fugitive_extensions').create_branch(<f-args>)]]
vim.cmd [[command! -nargs=0 Gcmaster :lua require('fugitive_extensions').checkout_branch('main')]]
vim.cmd [[command! -nargs=0 Gcm Gcmaster]]
vim.cmd [[command! -nargs=0 Gcdev :lua require('fugitive_extensions').checkout_branch('develop')]]
vim.cmd [[command! -nargs=1 Gcheckout :lua require('fugitive_extensions').checkout_branch(<f-args>)]]
vim.cmd [[command! -nargs=1 Gc Gcheckout <args>]]
vim.cmd([[command! -nargs=0 Ggpush :lua require('fugitive_extensions').push_origin()]])
vim.cmd([[command! -nargs=0 Ggpull :lua require('fugitive_extensions').pull_origin()]])
vim.cmd([[command! -nargs=? Gpropen :lua require('fugitive_extensions').open_new_pr(<f-args>)]])
vim.cmd([[command! -nargs=? Gpr Gpropen <args>]])
vim.cmd([[command! -nargs=? Gprprint :lua require('fugitive_extensions').print_pr_url(<f-args>)]])
vim.cmd([[command! -nargs=? Gprcopy :lua require('fugitive_extensions').copy_pr_url(<f-args>)]])
vim.cmd([[command! -nargs=1 Gcbranch :lua require('fugitive_extensions').create_branch(<f-args>)]])
vim.cmd([[command! -nargs=0 Gcmaster :lua require('fugitive_extensions').checkout_branch('main')]])
vim.cmd([[command! -nargs=0 Gcm Gcmaster]])
vim.cmd([[command! -nargs=0 Gcdev :lua require('fugitive_extensions').checkout_branch('develop')]])
vim.cmd([[command! -nargs=1 Gcheckout :lua require('fugitive_extensions').checkout_branch(<f-args>)]])
vim.cmd([[command! -nargs=1 Gc Gcheckout <args>]])

View File

@ -1,4 +1,4 @@
require('gitsigns').setup {
require("gitsigns").setup({
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
@ -9,32 +9,44 @@ require('gitsigns').setup {
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
map("n", "]c", function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
map("n", "[c", function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
-- Actions
map({'n', 'v'}, '<leader>hs', ':Gitsigns stage_hunk<CR>')
map({'n', 'v'}, '<leader>hr', ':Gitsigns reset_hunk<CR>')
map('n', '<leader>hS', gs.stage_buffer)
map('n', '<leader>hu', gs.undo_stage_hunk)
map('n', '<leader>hR', gs.reset_buffer)
map('n', '<leader>hp', gs.preview_hunk)
map('n', '<leader>hb', function() gs.blame_line{full=true} end)
map('n', '<leader>tb', gs.toggle_current_line_blame)
map('n', '<leader>hd', gs.diffthis)
map('n', '<leader>hD', function() gs.diffthis('~') end)
map('n', '<leader>td', gs.toggle_deleted)
map({ "n", "v" }, "<leader>hs", ":Gitsigns stage_hunk<CR>")
map({ "n", "v" }, "<leader>hr", ":Gitsigns reset_hunk<CR>")
map("n", "<leader>hS", gs.stage_buffer)
map("n", "<leader>hu", gs.undo_stage_hunk)
map("n", "<leader>hR", gs.reset_buffer)
map("n", "<leader>hp", gs.preview_hunk)
map("n", "<leader>hb", function()
gs.blame_line({ full = true })
end)
map("n", "<leader>tb", gs.toggle_current_line_blame)
map("n", "<leader>hd", gs.diffthis)
map("n", "<leader>hD", function()
gs.diffthis("~")
end)
map("n", "<leader>td", gs.toggle_deleted)
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
}
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
end,
})

View File

@ -2,4 +2,6 @@
-- - Local vimrc commands -
-------------------------------------------------------------------------------
vim.api.nvim_create_user_command("EditLocalVimrc", function(_) require"direnv_vimrc_local".open_local_vimrc() end, { nargs = 0 })
vim.api.nvim_create_user_command("EditLocalVimrc", function(_)
require("direnv_vimrc_local").open_local_vimrc()
end, { nargs = 0 })

View File

@ -13,7 +13,7 @@ local vim_readme_template = {
"",
"## License",
"",
"[LICENSE NAME](LICENSE)"
"[LICENSE NAME](LICENSE)",
}
local vim_doc_template = {
@ -97,16 +97,16 @@ local vim_doc_template = {
"",
"LICENSE *{}-license*",
"",
"vim:tw=78:ts=2:ft=help:norl:"
"vim:tw=78:ts=2:ft=help:norl:",
}
local flutter_config = {
["*"] = {
start = "flutter run"
start = "flutter run",
},
["lib/*.dart"] = {
alternate = "test/{}_test.dart",
type = "source"
type = "source",
},
["test/*_test.dart"] = {
alternate = "lib/{}.dart",
@ -119,15 +119,15 @@ local flutter_config = {
"void main() {",
" testWidgets('', (WidgetTester tester) async {",
" });",
"}"
}
}
"}",
},
},
}
local python_config = {
["*.py"] = {
alternate = "tests/{dirname}/test_{basename}.py",
type = "source"
type = "source",
},
["tests/**/test_*.py"] = {
alternate = "{dirname}/{basename}.py",
@ -141,9 +141,9 @@ local python_config = {
"",
"",
'if __name__ == "__main__":',
" unittest.main()"
}
}
" unittest.main()",
},
},
}
local dotnet_solution_config = {
@ -151,30 +151,30 @@ local dotnet_solution_config = {
type = "controller",
alternate = {
"tests/{dirname}.Tests/Controllers/{basename}Tests.cs",
"tests/{dirname}.IntegrationTests/Controllers/{basename}Tests.cs"
}
"tests/{dirname}.IntegrationTests/Controllers/{basename}Tests.cs",
},
},
["src/**/Models/*.cs"] = {
type = "model",
alternate = "tests/{dirname}.Tests/Models/{basename}Tests.cs"
alternate = "tests/{dirname}.Tests/Models/{basename}Tests.cs",
},
["src/**/Views/*.cshtml"] = {
type = "view",
alternate = "tests/{dirname}.Tests/Views/{basename}Tests.cs"
alternate = "tests/{dirname}.Tests/Views/{basename}Tests.cs",
},
["src/**/Services/*.cs"] = {
type = "service",
alternate = "tests/{dirname}.Tests/Services/{basename}Tests.cs"
alternate = "tests/{dirname}.Tests/Services/{basename}Tests.cs",
},
["src/**/Extensions/*.cs"] = {
type = "extension",
alternate = "tests/{dirname}.Tests/Extensions/{basename}Tests.cs"
alternate = "tests/{dirname}.Tests/Extensions/{basename}Tests.cs",
},
["*.csproj"] = {
type = "project"
type = "project",
},
["src/**/appsettings*json"] = {
type = "appsettings"
type = "appsettings",
},
["src/*.cs"] = {
type = "source",
@ -187,32 +187,32 @@ local dotnet_solution_config = {
" public class {basename}",
" {",
" }",
"}"
}
"}",
},
},
["tests/**.IntegrationTests/Controllers/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Controllers/{basename}.cs"
alternate = "src/{dirname}/Controllers/{basename}.cs",
},
["tests/**.Tests/Controllers/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Controllers/{basename}.cs"
alternate = "src/{dirname}/Controllers/{basename}.cs",
},
["tests/**.Tests/Views/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Views/{basename}.cs"
alternate = "src/{dirname}/Views/{basename}.cs",
},
["tests/**.Tests/Models/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Models/{basename}.cs"
alternate = "src/{dirname}/Models/{basename}.cs",
},
["tests/**.Tests/Services/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Services/{basename}.cs"
alternate = "src/{dirname}/Services/{basename}.cs",
},
["tests/**.Tests/Extensions/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Extensions/{basename}.cs"
alternate = "src/{dirname}/Extensions/{basename}.cs",
},
["tests/*Tests.cs"] = {
type = "test",
@ -225,68 +225,68 @@ local dotnet_solution_config = {
" public class {basename}Tests",
" {",
" }",
"}"
}
}
"}",
},
},
}
local vim_plugin_config = {
["doc/*.txt"] = {
type = "help",
template = vim_doc_template
template = vim_doc_template,
},
["autoload/*.vim"] = {
type = "autoload",
alternate = "test/{}.vader"
alternate = "test/{}.vader",
},
["test/*.vader"] = {
type = "test",
altername = "autoload/{}.vim"
altername = "autoload/{}.vim",
},
["plugin/*.vim"] = {
type = "plugin",
template = {
'if exists("g:loaded_{}") || &cp | finish | endif',
"",
"let g:loaded_{} = 1"
}
"let g:loaded_{} = 1",
},
},
["README.md"] = {
template = vim_readme_template
}
template = vim_readme_template,
},
}
local lua_vim_plugin_config = {
["doc/*.txt"] = {
type = "help",
template = vim_doc_template
template = vim_doc_template,
},
["plugin/*.vim"] = {
type = "plugin",
template = {
'if exists("g:loaded_{}") || &cp | finish | endif',
"",
"let g:loaded_{} = 1"
}
"let g:loaded_{} = 1",
},
},
["lua/*.lua"] = {
type = "source",
alternate = "test/{}.lua"
alternate = "test/{}.lua",
},
["test/*.lua"] = {
type = "test",
alternate = "lua/{}.lua"
alternate = "lua/{}.lua",
},
["README.md"] = {
template = vim_readme_template
}
template = vim_readme_template,
},
}
local csharp_project_config = {
["*"] = {
start = "dotnet run",
console = "dotnet fsi"
}
console = "dotnet fsi",
},
}
local java_project_config = {
@ -296,9 +296,9 @@ local java_project_config = {
"package {dirname|dot};",
"",
"public class {basename} {open}",
"{close}"
"{close}",
},
alternate = "src/test/java/{}Test.java"
alternate = "src/test/java/{}Test.java",
},
["src/test/java/*Test.java"] = {
type = "test",
@ -306,22 +306,22 @@ local java_project_config = {
"package {dirname|dot};",
"",
"public class {basename}Test {open}",
"{close}"
"{close}",
},
alternate = "src/main/java/{}.java"
alternate = "src/main/java/{}.java",
},
["src/main/java/module-info.java"] = {
type = "moduleinfo"
type = "moduleinfo",
},
["src/main/java/**/package-info.java"] = {
type = "packageinfo"
type = "packageinfo",
},
["src/main/resources/*"] = {
type = "resource"
type = "resource",
},
["src/test/resources/*"] = {
type = "testresource"
}
type = "testresource",
},
}
local kotlin_project_config = {
@ -331,9 +331,9 @@ local kotlin_project_config = {
"package {dirname|dot}",
"",
"class {basename} {open}",
"{close}"
"{close}",
},
alternate = "src/test/kotlin/{}Test.kt"
alternate = "src/test/kotlin/{}Test.kt",
},
["src/main/java/*.kt"] = {
type = "source",
@ -341,9 +341,9 @@ local kotlin_project_config = {
"package {dirname|dot}",
"",
"class {basename} {open}",
"{close}"
"{close}",
},
alternate = "src/test/java/{}Test.kt"
alternate = "src/test/java/{}Test.kt",
},
["src/test/kotlin/*Test.kt"] = {
type = "test",
@ -351,9 +351,9 @@ local kotlin_project_config = {
"package {dirname|dot}",
"",
"class {basename}Test {open}",
"{close}"
"{close}",
},
alternate = "src/main/kotlin/{}.kt"
alternate = "src/main/kotlin/{}.kt",
},
["src/test/java/*Test.kt"] = {
type = "test",
@ -361,21 +361,21 @@ local kotlin_project_config = {
"package {dirname|dot}",
"",
"class {basename}Test {open}",
"{close}"
"{close}",
},
alternate = "src/main/java/{}.kt"
alternate = "src/main/java/{}.kt",
},
["src/main/resources/*"] = {
type = "resource"
type = "resource",
},
["src/test/resources/*"] = {
type = "testresource"
}
type = "testresource",
},
}
local mint_config = {
["*"] = {
start = "mint start"
start = "mint start",
},
["source/*.mint"] = {
type = "source",
@ -386,9 +386,9 @@ local mint_config = {
"",
" fun render : Html {open}",
" {close}",
"{close}"
"{close}",
},
alternate = "tests/{}.mint"
alternate = "tests/{}.mint",
},
["tests/*.mint"] = {
type = "test",
@ -398,23 +398,23 @@ local mint_config = {
" with Test.Html {open}",
" {close}",
" {close}",
"{close}"
"{close}",
},
alternate = "source/{}.mint",
},
alternate = "source/{}.mint"
}
}
local crystal_config = {
["*"] = {
start = "crystal run"
start = "crystal run",
},
["src/*.cr"] = {
type = "source",
template = {
"module {capitalize|colons}",
"end"
"end",
},
alternate = "spec/{}_spec.cr"
alternate = "spec/{}_spec.cr",
},
["spec/*_spec.cr"] = {
type = "spec",
@ -425,43 +425,43 @@ local crystal_config = {
' it "works" do',
" false.should eq(true)",
" end",
"end"
"end",
},
alternate = "src/{}.cr",
},
alternate = "src/{}.cr"
}
}
local function c_project_config(source_extension, header_extension)
return {
["*"] = {
start = "make run"
start = "make run",
},
["src/*." .. source_extension] = {
type = "source",
alternate = {
"src/{}." .. header_extension,
"test/{}." .. source_extension,
"include/{project|basename}/{}." .. header_extension
}
"include/{project|basename}/{}." .. header_extension,
},
},
["test/*." .. source_extension] = {
type = "test",
alternate = {
"src/{}." .. header_extension
}
"src/{}." .. header_extension,
},
},
["src/*." .. header_extension] = {
type = "header",
alternate = {
"src/{}." .. source_extension
}
"src/{}." .. source_extension,
},
},
["include/{project|basename}/*." .. header_extension] = {
type = "header",
alternate = {
"src/{}." .. header_extension
}
}
"src/{}." .. header_extension,
},
},
}
end
@ -477,5 +477,5 @@ vim.g.projectionist_heuristics = {
["build.gradle|pom.xml"] = java_project_config,
["build.gradle|build.gradle.kts"] = kotlin_project_config,
["mint.json"] = mint_config,
["shard.yml"] = crystal_config
["shard.yml"] = crystal_config,
}

View File

@ -2,7 +2,15 @@
-- - Vim REST Console setup and extra commands -
-------------------------------------------------------------------------------
vim.cmd [[command! -nargs=0 ScratchRestConsole :lua require('vim_rest_console_extensions').open_scratch_rest_console()]]
vim.cmd [[command! -nargs=? RestConsole :lua require('vim_rest_console_extensions').open_cached_rest_console(<f-args>)]]
vim.cmd [[command! -nargs=? RestConsoleLocal :lua require('vim_rest_console_extensions').open_local_rest_console(<f-args>)]]
vim.cmd [[command! -nargs=1 RestConsoleCached :lua require('vim_rest_console_extensions').open_named_cached_rest_console(<f-args>)]]
vim.cmd(
[[command! -nargs=0 ScratchRestConsole :lua require('vim_rest_console_extensions').open_scratch_rest_console()]]
)
vim.cmd(
[[command! -nargs=? RestConsole :lua require('vim_rest_console_extensions').open_cached_rest_console(<f-args>)]]
)
vim.cmd(
[[command! -nargs=? RestConsoleLocal :lua require('vim_rest_console_extensions').open_local_rest_console(<f-args>)]]
)
vim.cmd(
[[command! -nargs=1 RestConsoleCached :lua require('vim_rest_console_extensions').open_named_cached_rest_console(<f-args>)]]
)

View File

@ -3,9 +3,15 @@ local s = luasnip.snippet
local f = luasnip.function_node
luasnip.add_snippets("all", {
s("date", {f(function(_, _) return os.date("%Y-%m-%d") end)}),
s("datetime", {f(function(_, _) return os.date("%Y-%m-%d %H:%M:%S") end)}),
s("diso", {f(function(_, _) return os.date("%Y-%m-%dT%H:%M:%S") end)})
s("date", { f(function(_, _)
return os.date("%Y-%m-%d")
end) }),
s("datetime", { f(function(_, _)
return os.date("%Y-%m-%d %H:%M:%S")
end) }),
s("diso", { f(function(_, _)
return os.date("%Y-%m-%dT%H:%M:%S")
end) }),
})
require("luasnip.loaders.from_vscode").lazy_load()

View File

@ -3,36 +3,28 @@
-------------------------------------------------------------------------------
local actions = require("telescope.actions")
require("telescope").setup {
require("telescope").setup({
defaults = {
mappings = {
i = {
-- Switch out M-q and C-q since C-q will be used more often
["<M-q>"] = actions.send_to_qflist + actions.open_qflist,
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
},
n = {
-- Switch out M-q and C-q since C-q will be used more often
["<M-q>"] = actions.send_to_qflist + actions.open_qflist,
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist
}
}
}
}
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
},
},
},
})
require("telescope").load_extension("dap")
vim.keymap.set(
"n",
"<C-P>",
function()
vim.keymap.set("n", "<C-P>", function()
require("telescope.builtin").find_files()
end
)
vim.keymap.set(
"n",
"<C-M-F>",
function()
end)
vim.keymap.set("n", "<C-M-F>", function()
require("telescope.builtin").live_grep()
end
)
end)

View File

@ -1,16 +1,13 @@
require "nvim-treesitter.configs".setup {
require("nvim-treesitter.configs").setup({
ensure_installed = "all", -- "all" or a list of languages
highlight = {
enable = true -- false will disable the whole extension
},
indent = {
enable = true
enable = true, -- false will disable the whole extension
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false -- Whether the query persists across vim sessions
persist_queries = false, -- Whether the query persists across vim sessions
},
textobjects = {
select = {
@ -18,31 +15,31 @@ require "nvim-treesitter.configs".setup {
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
},
}
})