This commit is contained in:
max_richter 2022-01-26 20:42:58 +01:00
parent 3d32043a89
commit b54da97755
14 changed files with 486 additions and 357 deletions

View File

@ -38,6 +38,7 @@
autoload -Uz is-at-least && is-at-least 5.1 || return autoload -Uz is-at-least && is-at-least 5.1 || return
# Prompt colors. # Prompt colors.
local main='242'
local grey='242' local grey='242'
local red='1' local red='1'
local yellow='3' local yellow='3'
@ -76,7 +77,7 @@
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false
# Magenta prompt symbol if the last command succeeded. # Magenta prompt symbol if the last command succeeded.
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$grey typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$main
# Red prompt symbol if the last command failed. # Red prompt symbol if the last command failed.
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red
# Default prompt symbol. # Default prompt symbol.

0
configs/init.lua Normal file
View File

View File

@ -10,8 +10,6 @@ local opt = vim.opt
require("plugins") require("plugins")
if u.has_plugin("cmp") then if u.has_plugin("cmp") then
vim.g.did_load_filetypes = 150
-- Global options -- Global options
o.number = true -- show line number o.number = true -- show line number
o.showmatch = true -- show matching brackets o.showmatch = true -- show matching brackets
@ -28,6 +26,7 @@ if u.has_plugin("cmp") then
g.hidden = true -- unload buffers when hidden g.hidden = true -- unload buffers when hidden
g.filetype = true -- execute autocommands based on filetype g.filetype = true -- execute autocommands based on filetype
o.autoread = true o.autoread = true
opt.termguicolors = true
-- Search -- Search
o.inccommand = "nosplit" -- show substitutions incrementally o.inccommand = "nosplit" -- show substitutions incrementally
@ -68,6 +67,31 @@ if u.has_plugin("cmp") then
g.ale_fixers = {"prettier", "eslint"} g.ale_fixers = {"prettier", "eslint"}
vim.notify = require("notify")
require("notify").setup(
{
stages = "fade_in_slide_out",
render = "minimal",
background_colour = "#000000",
icons = {
ERROR = "",
WARN = "",
INFO = "",
DEBUG = "",
TRACE = ""
}
}
)
require("telescope").setup {
pickers = {
find_files = {
hidden = true
}
}
}
-- Enable Theming / Syntax -- Enable Theming / Syntax
o.syntax = "enable" o.syntax = "enable"
o.termguicolors = true o.termguicolors = true
@ -82,10 +106,12 @@ if u.has_plugin("cmp") then
} }
) )
require("transparent").setup({ require("transparent").setup(
{
enable = true, enable = true,
extra_groups = "All" extra_groups = "All"
}) }
)
-- Remove background color -- Remove background color
cmd("highlight Normal guibg=none") cmd("highlight Normal guibg=none")
@ -169,6 +195,8 @@ if u.has_plugin("cmp") then
-- KeyBindings -- KeyBindings
require "keymappings" require "keymappings"
require "overlays"
require "nvim-tmux-navigation".setup { require "nvim-tmux-navigation".setup {
keybindings = { keybindings = {
left = "<C-h>", left = "<C-h>",

View File

@ -1,4 +1,4 @@
local cmd = vim.cmd; local cmd = vim.cmd
cmd [[ cmd [[
augroup highlight_yank augroup highlight_yank
@ -6,3 +6,8 @@ cmd [[
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 150 } au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 150 }
augroup END augroup END
]] ]]
cmd [[
au ColorScheme * hi Normal ctermbg=none guibg=none
au ColorScheme myspecialcolors hi Normal ctermbg=red guibg=red
]]

View File

@ -1,25 +1,30 @@
-- luasnip setup -- luasnip setup
local cmd = vim.cmd; local cmd = vim.cmd
local luasnip = require "luasnip" local luasnip = require "luasnip"
local lspkind = require "lspkind" local lspkind = require "lspkind"
local cmp = require "cmp" local cmp = require "cmp"
local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.setup { cmp.setup {
formatting = { formatting = {
format = lspkind.cmp_format({with_text = true, menu = ({ format = lspkind.cmp_format(
{
with_text = true,
menu = ({
buffer = "[Buffer]", buffer = "[Buffer]",
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]", luasnip = "[LuaSnip]",
nvim_lua = "[Lua]", nvim_lua = "[Lua]",
latex_symbols = "[Latex]", latex_symbols = "[Latex]"
})}), })
}
)
}, },
experimental = { experimental = {
ghost_text = true, ghost_text = true
}, },
completion = { completion = {
completeopt = "menu,menuone", completeopt = "menu,menuone"
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
@ -27,7 +32,7 @@ cmp.setup {
end end
}, },
mapping = { mapping = {
['<C-Leader>'] = cmp.mapping.complete(), ["<C-Leader>"] = cmp.mapping.complete(),
["<Tab>"] = function(fallback) ["<Tab>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
@ -42,13 +47,15 @@ cmp.setup {
fallback() fallback()
end end
end, end,
['<CR>'] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm(
{
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true
}), }
)
}, },
sources = { sources = {
{name = "nvim-lua"}, {name = "nvim_lua"},
{name = "nvim_lsp"}, {name = "nvim_lsp"},
{name = "luasnip"}, {name = "luasnip"},
{name = "path"}, {name = "path"},
@ -58,27 +65,35 @@ cmp.setup {
} }
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', { cmp.setup.cmdline(
"/",
{
sources = { sources = {
{ name = 'buffer' } {name = "buffer"}
} }
}) }
)
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', { cmp.setup.cmdline(
sources = cmp.config.sources({ ":",
{ name = 'path' } {
}, { sources = cmp.config.sources(
{ name = 'cmdline' } {
}) {name = "path"}
}) },
{
{name = "cmdline"}
}
)
}
)
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. -- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
-- Setup lspconfig. -- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'.html.setup { require "lspconfig".html.setup {
capabilities = capabilities capabilities = capabilities
} }
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({map_char = {tex = ""}}))

View File

@ -1,8 +1,59 @@
local cmd = vim.cmd local cmd = vim.cmd
local util = require "vim.lsp.util"
local utils = require("utils")
function tablelength(T)
local count = 0
for _ in pairs(T) do
count = count + 1
end
return count
end
local function select_client(method)
local all_clients = vim.tbl_values(vim.lsp.buf_get_clients())
local supported_client
local found_client = false
for _, client in ipairs(all_clients) do
local supports = client.supports_method(method)
if supports then
found_client = true
supported_client = client
end
end
if not found_client then
return nil
end
return supported_client
end
function FormattingSync()
vim.cmd("Neoformat")
-- local client = select_client("textDocument/formatting")
-- if client == nil then
-- vim.notify("No LSP Client with formatting connected")
-- end
-- vim.notify("Formatting with LSP")
-- local params = util.make_formatting_params({})
-- local result, err = client.request_sync("textDocument/formatting", params, 500, vim.api.nvim_get_current_buf())
-- if result and result.result then
-- util.apply_text_edits(result.result)
-- elseif err then
-- vim.notify("vim.lsp.buf.formatting_sync: " .. err, vim.log.levels.WARN)
-- end
end
vim.cmd [[command! Format lua FormattingSync()]]
cmd [[ cmd [[
augroup auto_format augroup auto_format
au! au!
au BufWritePre * Neoformat au BufWritePre * lua FormattingSync()
augroup END augroup END
]] ]]

View File

@ -1,6 +1,6 @@
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local g = vim.g local g = vim.g
local cmd = vim.cmd; local cmd = vim.cmd
local options = {noremap = true} local options = {noremap = true}
local remap = {noremap = false} local remap = {noremap = false}
@ -19,7 +19,7 @@ map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", options)
map("n", "<Leader>e", "<cmd>lua vim.diagnostic.open_float()<CR>", options) map("n", "<Leader>e", "<cmd>lua vim.diagnostic.open_float()<CR>", options)
map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", options) map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", options)
map("n", "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", options) map("n", "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", options)
map("n", "<Leader><C-f>", ":Format<CR>", options) map("n", "<Leader><C-f>", ":Neoformat<CR>", options)
map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", options) map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", options)
map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", options) map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", options)
map("n", "<leader>t", ":TroubleToggle<CR>", remap) map("n", "<leader>t", ":TroubleToggle<CR>", remap)
@ -41,8 +41,8 @@ map("i", "<A-j>", "<cmd>move +1<CR>", options)
map("i", "<A-k>", "<cmd>move -2<CR>", options) map("i", "<A-k>", "<cmd>move -2<CR>", options)
map("v", "<A-j>", ":m '>+1<CR>gv=gv", options) map("v", "<A-j>", ":m '>+1<CR>gv=gv", options)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", options) map("v", "<A-k>", ":m '<-2<CR>gv=gv", options)
map("n", "<A-S-k>", "YP", options); map("n", "<A-S-k>", "YP", options)
map("n", "<A-S-j>", "Yp", options); map("n", "<A-S-j>", "Yp", options)
-- Faster git merge -- Faster git merge
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options) map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)

View File

@ -13,7 +13,6 @@ end
-- function to attach completion when setting up lsp -- function to attach completion when setting up lsp
local function on_attach() local function on_attach()
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
vim.cmd("command! LspOrganize lua lsp_organize_imports()") vim.cmd("command! LspOrganize lua lsp_organize_imports()")
vim.api.nvim_buf_map(bufnr, "n", "gs", ":LspOrganize<CR>", {silent = true}) vim.api.nvim_buf_map(bufnr, "n", "gs", ":LspOrganize<CR>", {silent = true})
end end
@ -91,6 +90,12 @@ lsp.svelte.setup {
lsp.tsserver.setup { lsp.tsserver.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = lsp_status.capabilities, capabilities = lsp_status.capabilities,
commands = {
OrganizeImports = {
organize_imports,
description = "Organize Imports"
}
}
} }
-- JSON ls setup -- JSON ls setup

View File

@ -63,6 +63,20 @@ end
vim.api.nvim_set_keymap("n", "<Leader><C-i>", "<cmd>lua _nvimConfig_toggle()<CR>", {noremap = true, silent = true}) vim.api.nvim_set_keymap("n", "<Leader><C-i>", "<cmd>lua _nvimConfig_toggle()<CR>", {noremap = true, silent = true})
local chtConfig =
Terminal:new(
{
cmd = "cht",
direction = "float"
}
)
function _chtConfig_toggle()
chtConfig:toggle()
end
vim.api.nvim_set_keymap("n", "<Leader><C-l>", "<cmd>lua _chtConfig_toggle()<CR>", {noremap = true, silent = true})
require("toggleterm").setup { require("toggleterm").setup {
shade_terminals = true shade_terminals = true
} }

View File

@ -1,5 +1,5 @@
return require("packer").startup(function() return require("packer").startup(
function()
-- Let packer manage itself -- Let packer manage itself
use "wbthomason/packer.nvim" use "wbthomason/packer.nvim"
@ -10,11 +10,9 @@ return require("packer").startup(function()
use "nathom/filetype.nvim" use "nathom/filetype.nvim"
use "alexghergh/nvim-tmux-navigation" use "alexghergh/nvim-tmux-navigation"
use 'lervag/vimtex'
-- Theming Section -- Theming Section
-- use 'folke/tokyonight.nvim' -- use 'folke/tokyonight.nvim'
use 'EdenEast/nightfox.nvim' use "EdenEast/nightfox.nvim"
use "xiyaowong/nvim-transparent" use "xiyaowong/nvim-transparent"
-- Layout Plugins -- Layout Plugins
@ -22,12 +20,11 @@ return require("packer").startup(function()
use "kyazdani42/nvim-tree.lua" use "kyazdani42/nvim-tree.lua"
use "nvim-lua/popup.nvim" use "nvim-lua/popup.nvim"
use "mhinz/vim-startify" use "mhinz/vim-startify"
use "karb94/neoscroll.nvim"
use "tpope/vim-fugitive" use "tpope/vim-fugitive"
use "tpope/vim-commentary"
use "tpope/vim-surround" use "tpope/vim-surround"
use "lambdalisue/suda.vim" use "lambdalisue/suda.vim"
use "editorconfig/editorconfig-vim" use "windwp/nvim-autopairs"
-- Code Navigation -- Code Navigation
use "dense-analysis/ale" use "dense-analysis/ale"
@ -41,6 +38,8 @@ return require("packer").startup(function()
-- Obsidian / Roam like features -- Obsidian / Roam like features
-- use "lervag/wiki.vim" -- use "lervag/wiki.vim"
use "rcarriga/nvim-notify"
-- Lsp Errors -- Lsp Errors
use "folke/lsp-colors.nvim" use "folke/lsp-colors.nvim"
use "onsails/lspkind-nvim" use "onsails/lspkind-nvim"
@ -54,7 +53,6 @@ return require("packer").startup(function()
-- Syntax / Autocomplete -- Syntax / Autocomplete
use "neovim/nvim-lspconfig" use "neovim/nvim-lspconfig"
-- use "github/copilot.vim"
use "hrsh7th/nvim-cmp" use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-nvim-lsp" use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua" use "hrsh7th/cmp-nvim-lua"
@ -65,22 +63,17 @@ return require("packer").startup(function()
use "L3MON4D3/LuaSnip" use "L3MON4D3/LuaSnip"
use "saadparwaiz1/cmp_luasnip" use "saadparwaiz1/cmp_luasnip"
use "rafamadriz/friendly-snippets" use "rafamadriz/friendly-snippets"
use "beyondmarc/glsl.vim"
use "tpope/vim-commentary"
use "williamboman/nvim-lsp-installer" use "williamboman/nvim-lsp-installer"
use "nvim-lua/lsp-status.nvim" use "nvim-lua/lsp-status.nvim"
use "windwp/nvim-autopairs"
use "neoclide/jsonc.vim" use "neoclide/jsonc.vim"
use { use {
'nvim-treesitter/nvim-treesitter', "nvim-treesitter/nvim-treesitter",
run = ':TSUpdate' run = ":TSUpdate"
} }
-- Preview Markdown -- Language Supports
use "ellisonleao/glow.nvim" use "beyondmarc/glsl.vim" -- GLSL
use "ellisonleao/glow.nvim" -- MARKDOWN
-- Autoformat -- Autoformat
use "sbdchd/neoformat" use "sbdchd/neoformat"
@ -92,5 +85,5 @@ return require("packer").startup(function()
-- Database Feature -- Database Feature
use "tpope/vim-dadbod" use "tpope/vim-dadbod"
use "kristijanhusak/vim-dadbod-ui" use "kristijanhusak/vim-dadbod-ui"
end
end) )

View File

@ -28,7 +28,8 @@ local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
"javascript", "javascript",
"go", "go",
"lua", "lua",
"yaml" "yaml",
"prisma"
}, },
highlight = {enable = true} highlight = {enable = true}
} }

View File

@ -35,6 +35,8 @@ local function dump(o)
end end
end end
M.dump = dump
function M.has_plugin(pluginName) function M.has_plugin(pluginName)
local status = pcall(require, pluginName) local status = pcall(require, pluginName)
return status return status

View File

@ -7,3 +7,4 @@ source $(dirname "$0")/functions/rn.zsh;
source $(dirname "$0")/functions/sum.zsh; source $(dirname "$0")/functions/sum.zsh;
source $(dirname "$0")/functions/mke.zsh; source $(dirname "$0")/functions/mke.zsh;
source $(dirname "$0")/functions/myip.zsh; source $(dirname "$0")/functions/myip.zsh;
source $(dirname "$0")/functions/cht.zsh;

View File

@ -0,0 +1,13 @@
languages=`echo "golang lua cpp c typescript nodejs" | tr ' ' '\n'`
core_utils=`echo "xargs find mv sed awk" | tr ' ' '\n'`
function cht(){
selected=`printf "$languages\n$core_utils" | fzf`
read query\?"query:"
if printf $languages | grep -qs $selected; then
curl cht.sh/$selected/`echo $query | tr ' ' '+'`
else
curl cht.sh/$selected~$query
fi
}