aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/diagnostic.lua12
-rw-r--r--lua/alpha/keybindings.lua45
-rw-r--r--lua/alpha/packer_install.lua (renamed from lua/alpha/first_load.lua)0
-rw-r--r--lua/alpha/plugins.lua45
-rw-r--r--lua/alpha/setter_getter_template.lua99
-rw-r--r--lua/alpha/settings.lua1
-rw-r--r--lua/alpha/utils.lua61
7 files changed, 114 insertions, 149 deletions
diff --git a/lua/alpha/diagnostic.lua b/lua/alpha/diagnostic.lua
new file mode 100644
index 0000000..543732f
--- /dev/null
+++ b/lua/alpha/diagnostic.lua
@@ -0,0 +1,12 @@
+vim.keymap.set("n", "<leader>vn", vim.diagnostic.goto_next, {})
+vim.keymap.set("n", "<leader>vp", vim.diagnostic.goto_prev, {})
+
+vim.diagnostic.config({
+ virtual_text = false,
+})
+
+local signs = { Error = "", Warn = "", Hint = "", Info = "" }
+for type, icon in pairs(signs) do
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
+end
diff --git a/lua/alpha/keybindings.lua b/lua/alpha/keybindings.lua
new file mode 100644
index 0000000..ca4dd3a
--- /dev/null
+++ b/lua/alpha/keybindings.lua
@@ -0,0 +1,45 @@
+local map = vim.keymap.set
+
+map("v", "<leader>p", '"_dp')
+
+map("n", "bd", ":bd!<CR>")
+
+-- lists navigation
+map("n", "<leader>j", ":cnext<CR>zz")
+map("n", "<leader>k", ":cprev<CR>zz")
+map("n", "<leader>i", ":lnext<CR>zz")
+map("n", "<leader>o", ":lprev<CR>zz")
+map("n", "<leader>cc", ":cclose<CR>")
+
+-- quick split
+map("n", "<leader>wsv", ":vsp<CR>")
+
+-- tabulation
+map("v", "<", "<gv")
+map("v", ">", ">gv")
+
+-- symbols to add undo points
+local symbols = { ",", ".", "!", "?", "$", ">", "<" }
+for _, symbol in pairs(symbols) do
+ map("i", symbol, symbol .. "<c-g>u")
+end
+
+-- search result focus
+map("n", "n", "nzzzv")
+map("n", "N", "Nzzzv")
+
+-- join lines focus
+map("n", "J", "mzJ`z")
+
+-- Terminal
+map("t", "<Esc><Esc>", "<C-\\><C-n>")
+map("t", "<C-w>h", "<C-\\><C-n><C-w>h")
+map("t", "<C-w>j", "<C-\\><C-n><C-w>j")
+map("t", "<C-w>k", "<C-\\><C-n><C-w>k")
+map("t", "<C-w>l", "<C-\\><C-n><C-w>l")
+
+-- quick env file edit
+map("n", "<leader>ee", ":vsp .env<CR>")
+
+-- quick save and exec
+map("n", "<leader><leader>x", require("alpha.utils").save_and_exec)
diff --git a/lua/alpha/first_load.lua b/lua/alpha/packer_install.lua
index 9ef6658..9ef6658 100644
--- a/lua/alpha/first_load.lua
+++ b/lua/alpha/packer_install.lua
diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua
index ea4fe4a..12bca66 100644
--- a/lua/alpha/plugins.lua
+++ b/lua/alpha/plugins.lua
@@ -1,3 +1,7 @@
+if require("alpha.packer_install")() then
+ return
+end
+
vim.cmd.packadd("packer.nvim")
vim.cmd([[autocmd BufWritePost plugins.lua source <afile> | PackerCompile]])
@@ -81,7 +85,7 @@ return require("packer").startup(function(use)
"rcarriga/cmp-dap",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind-nvim",
- {"L3MON4D3/LuaSnip", tag = "v1.*"},
+ { "L3MON4D3/LuaSnip", tag = "v1.*" },
"windwp/nvim-autopairs",
},
})
@@ -139,7 +143,7 @@ return require("packer").startup(function(use)
"theHamsta/nvim-dap-virtual-text",
"rcarriga/nvim-dap-ui",
"leoluz/nvim-dap-go",
- "mxsdev/nvim-dap-vscode-js",
+ "mxsdev/nvim-dap-vscode-js",
},
})
@@ -170,26 +174,32 @@ return require("packer").startup(function(use)
end,
})
- -- Themes
+ -- Themes
use("EdenEast/nightfox.nvim")
use("folke/tokyonight.nvim")
use("wuelnerdotexe/vim-enfocado")
- use("voldikss/vim-floaterm")
+ -- use("voldikss/vim-floaterm")
+ -- Style
use("stevearc/dressing.nvim")
use("rcarriga/nvim-notify")
use("xiyaowong/nvim-transparent")
use("Raimondi/delimitMate")
+ use("lukas-reineke/indent-blankline.nvim")
+
use("tpope/vim-surround")
- use("tpope/vim-dotenv")
- use("tpope/vim-fugitive")
use("tpope/vim-repeat")
+ use("tpope/vim-fugitive")
+ use("tpope/vim-rhubarb")
+ use("tpope/vim-dotenv")
use("tpope/vim-eunuch")
- use("tpope/vim-commentary")
- use("tpope/vim-tbone")
- use("tpope/vim-dispatch")
+
+ use({"numToStr/Comment.nvim", config = function ()
+ require('Comment').setup()
+ end})
+ use("tpope/vim-sleuth")
use("junegunn/vim-easy-align")
@@ -202,6 +212,7 @@ return require("packer").startup(function(use)
},
})
+ -- Database client
use({
"kristijanhusak/vim-dadbod-ui",
requires = {
@@ -211,6 +222,7 @@ return require("packer").startup(function(use)
},
})
+ -- Rest client
use({
"NTBBloodbath/rest.nvim",
requires = { "nvim-lua/plenary.nvim" },
@@ -227,9 +239,22 @@ return require("packer").startup(function(use)
requires = { "nvim-lua/plenary.nvim" },
})
+ use({
+ "jackMort/ChatGPT.nvim",
+ config = function()
+ require("chatgpt").setup({
+ -- optional configuration
+ })
+ end,
+ requires = {
+ "MunifTanjim/nui.nvim",
+ "nvim-lua/plenary.nvim",
+ "nvim-telescope/telescope.nvim",
+ },
+ })
+
-- Local plugins can be included
local_use("telescope-projectionist.nvim")
- -- local_use("telescope-laravel.nvim")
local_use("php-code-actions.nvim")
local_use("laravel.nvim")
local_use("composer.nvim")
diff --git a/lua/alpha/setter_getter_template.lua b/lua/alpha/setter_getter_template.lua
deleted file mode 100644
index fc2099f..0000000
--- a/lua/alpha/setter_getter_template.lua
+++ /dev/null
@@ -1,99 +0,0 @@
-local utils = require("alpha.utils")
-
-local M = {}
-
-local function isNullable(nullable)
- if nullable then
- return "?"
- end
-
- return ""
-end
-
-local function getReturnTypes(nullable, types) if #types > 0 then
- return string.format(": %s%s", isNullable(nullable), table.concat(types, "|"))
- end
- return ""
-end
-
-local function getTypeHint(nullable, types) if #types > 0 then
- return string.format("%s%s ", isNullable(nullable), table.concat(types, "|"))
- end
- return ""
-end
-
-
-local function toTable(fn)
- local t = {}
- -- todo check why removes all lines
- for s in fn:gmatch("[^\r\n]+") do
- table.insert(t, s)
- end
-
- return t
-end
-
-M.getGetter = function(property, nullable, types, have_dock_block)
- local comment = ""
- if have_dock_block and #types > 0 then
- comment = string.format(
- [[
- /**
- * @return %s
- */
-]],
- table.concat(types, "|")
- )
- end
-
- local fn = string.format(
- [[
- public function get%s()%s
- {
- return $this->%s;
- }
- ]] ,
- utils.ucfirst(property),
- getReturnTypes(nullable, types),
- property
- )
-
- return toTable(comment .. fn)
-end
-
-M.getSetter = function(property, nullable, types, have_dock_block)
-
- local comment = ""
- if have_dock_block and #types > 0 then
- comment = string.format(
- [[
- /**
- * @param %s $%s
- *
- * @return self
- */
-]],
- table.concat(types, "|"),
- property
- )
- end
- local fn = string.format(
- [[
- public function set%s(%s$%s): self
- {
- $this->%s = $%s;
-
- return $this;
- }
- ]] ,
- utils.ucfirst(property),
- getTypeHint(nullable, types),
- property,
- property,
- property
- )
-
- return toTable(comment .. fn)
-end
-
-return M
diff --git a/lua/alpha/settings.lua b/lua/alpha/settings.lua
index 51efb63..0d012f6 100644
--- a/lua/alpha/settings.lua
+++ b/lua/alpha/settings.lua
@@ -30,7 +30,6 @@ options.scrolloff = 4
options.sidescrolloff = 4
options.showmode = false
options.clipboard = "unnamedplus"
--- set completeopt=menuone,noinsert,noselect
options.splitbelow = true
options.splitright = true
options.autowrite = true
diff --git a/lua/alpha/utils.lua b/lua/alpha/utils.lua
index f1de150..b1911bc 100644
--- a/lua/alpha/utils.lua
+++ b/lua/alpha/utils.lua
@@ -1,41 +1,24 @@
-local ts_utils = require("nvim-treesitter.ts_utils")
-
-local M = {}
-
-M.ucfirst = function(str)
- return (str:gsub("^%l", string.upper))
-end
-
-M.get_master_node = function()
- local node = ts_utils.get_node_at_cursor()
- if node == nil then
- error("No treesitter parser found.")
- end
-
- local start_row = node:start()
-
- local parent = node:parent()
- while (parent ~= nil and parent:start() == start_row) do
- node = parent
- parent = node:parent()
- end
-
- return node
-end
-
-M.get_root_node = function ()
- local node = ts_utils.get_node_at_cursor()
- if node == nil then
- error("No treesitter parser found.")
- end
-
- local parent = node:parent()
- while (parent ~= nil) do
- node = parent
- parent = node:parent()
- end
-
- return node
+local utils = {}
+
+utils.save_and_exec = function()
+ local source_commands = {
+ lua = "luafi %",
+ vim = "source %",
+ }
+
+ local ft = vim.api.nvim_buf_get_option(0, "filetype")
+ local command = source_commands[ft]
+ if command == nil then
+ vim.notify("This type cant not be sourced", vim.log.levels.ERROR)
+ return
+ end
+
+ -- Save and source
+ vim.api.nvim_command("silent w")
+ vim.api.nvim_command(command)
+
+ local current_file_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t")
+ vim.notify(string.format("File %s Sourced", current_file_name), vim.log.levels.INFO)
end
-return M
+return utils