way too lazy to sort this out, adding kitchen sink
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
local status_ok, autopairs = pcall(require, "nvim-autopairs")
|
||||
local status_ok, autopairs = pcall(require, "ultimate-autopair")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
@ -10,10 +10,6 @@ local has_words_before = function()
|
||||
[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
-- insert '()' after completing a function
|
||||
cmp.event:on('confirm_done',
|
||||
require('nvim-autopairs.completion.cmp').on_confirm_done())
|
||||
|
||||
local luasnip = require('luasnip')
|
||||
local neogen = require('neogen')
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
@ -27,6 +23,7 @@ cmp.setup {
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp', keyword_length = 3 },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'luasnip_choice' },
|
||||
{ name = 'async_path' },
|
||||
{ name = 'buffer', keyword_length = 3, max_item_count = 7 },
|
||||
|
@ -4,9 +4,6 @@ if not status_ok then
|
||||
end
|
||||
|
||||
yodel.setup {
|
||||
diffpreview = {
|
||||
border = 'shadow',
|
||||
width = 'auto',
|
||||
height = 'auto',
|
||||
}
|
||||
position = 'auto'
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
local status_ok, hlargs = pcall(require, "hlargs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
hlargs.setup {}
|
@ -3,11 +3,21 @@ if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local function lsp_keymaps(bufnr)
|
||||
-- configure lsp when attached
|
||||
local function lsp_attach(client, bufnr)
|
||||
-- helper functions
|
||||
local function set_lsp_sign(name, text)
|
||||
vim.fn.sign_define(name, { text = text, texthl = name })
|
||||
end
|
||||
|
||||
local map = function(m, lhs, rhs)
|
||||
local opts = {remap = false, silent = true, buffer = bufnr}
|
||||
local opts = { remap = false, silent = true, buffer = bufnr }
|
||||
vim.keymap.set(m, lhs, rhs, opts)
|
||||
end
|
||||
set_lsp_sign("DiagnosticSignError", "x")
|
||||
set_lsp_sign("DiagnosticSignWarn" , "!")
|
||||
set_lsp_sign("DiagnosticSignInfo" , "i")
|
||||
set_lsp_sign("DiagnosticSignHint" , "h")
|
||||
|
||||
-- LSP actions
|
||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||
@ -17,64 +27,43 @@ local function lsp_keymaps(bufnr)
|
||||
map('n', 'gY', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||
map('n', 'gR', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||
map('n', '<S-Tab>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
||||
map('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||
map('n', '<leader>lr', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||
map('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
||||
|
||||
-- Diagnostics
|
||||
map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
||||
map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspFormat', function()
|
||||
vim.lsp.buf.format()
|
||||
end, {desc = 'Format buffer with language server'})
|
||||
vim.api.nvim_buf_create_user_command('LspWorkspaceAdd', function()
|
||||
vim.lsp.buf.add_workspace_folder()
|
||||
end, { desc = 'Add folder to workspace' })
|
||||
vim.api.nvim_buf_create_user_command('LspWorkspaceList', function()
|
||||
vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, { desc = 'List workspace folders' })
|
||||
vim.api.nvim_buf_create_user_command('LspWorkspaceRemove', function()
|
||||
vim.lsp.buf.remove_workspace_folder()
|
||||
end, { desc = 'Remove folder from workspace' })
|
||||
end
|
||||
|
||||
local function set_lsp_sign(name, text)
|
||||
vim.fn.sign_define(name, {text = text, texthl = name})
|
||||
end
|
||||
set_lsp_sign("DiagnosticSignError", "x")
|
||||
set_lsp_sign("DiagnosticSignWarn" , "!")
|
||||
set_lsp_sign("DiagnosticSignInfo" , "i")
|
||||
set_lsp_sign("DiagnosticSignHint" , "h")
|
||||
|
||||
local function lsp_settings()
|
||||
vim.diagnostic.config({
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
})
|
||||
})
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( vim.lsp.handlers.hover,
|
||||
{ border = 'shadow', }
|
||||
)
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help,
|
||||
{border = 'shadow'}
|
||||
)
|
||||
local command = vim.api.nvim_create_user_command
|
||||
command('LspWorkspaceAdd', function()
|
||||
vim.lsp.buf.add_workspace_folder()
|
||||
end, {desc = 'Add folder to workspace'})
|
||||
command('LspWorkspaceList', function()
|
||||
vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, {desc = 'List workspace folders'})
|
||||
command('LspWorkspaceRemove', function()
|
||||
vim.lsp.buf.remove_workspace_folder()
|
||||
end, {desc = 'Remove folder from workspace'})
|
||||
end
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover,
|
||||
{ border = 'shadow', })
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, { border = 'shadow' })
|
||||
|
||||
local function lsp_attach(client, bufnr)
|
||||
local buf_command = vim.api.nvim_buf_create_user_command
|
||||
|
||||
lsp_keymaps(bufnr)
|
||||
|
||||
buf_command(bufnr, 'LspFormat', function()
|
||||
vim.lsp.buf.format()
|
||||
end, {desc = 'Format buffer with language server'})
|
||||
end
|
||||
|
||||
lsp_settings()
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({})
|
||||
-- get servers and attach to them
|
||||
require('mason').setup {}
|
||||
require('mason-lspconfig').setup {}
|
||||
|
||||
local get_servers = require('mason-lspconfig').get_installed_servers
|
||||
for _, server_name in ipairs(get_servers()) do
|
||||
|
@ -3,7 +3,7 @@ if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
lines.setup {}
|
||||
lines.setup()
|
||||
|
||||
vim.diagnostic.config {
|
||||
virtual_lines = {
|
||||
|
@ -71,7 +71,7 @@ el.setup {
|
||||
hl_delete = hl("GitSignsDelete", true),
|
||||
}},
|
||||
{ { " " }, c.line {
|
||||
fmt = "ʟ[%s]",
|
||||
fmt = "[%s]",
|
||||
}, required = true },
|
||||
}
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ telescope.setup {
|
||||
local extension = split_path[#split_path]
|
||||
return vim.tbl_contains(image_extensions, extension)
|
||||
end
|
||||
if is_image(filepath) then
|
||||
if is_image(filepath) and vim.fn.executable('chafa') == 1 then
|
||||
local term = vim.api.nvim_open_term(bufnr, {})
|
||||
local function send_output(_, data, _)
|
||||
for _, d in ipairs(data) do
|
||||
@ -57,7 +57,7 @@ telescope.setup {
|
||||
end
|
||||
vim.fn.jobstart({
|
||||
'chafa', '-C', 'on', '--animate', 'off', '-s',
|
||||
(telescopew() - 10)..'x20', '--clear', filepath
|
||||
'23x18', '--clear', filepath
|
||||
}, { on_stdout = send_output, stdout_buffered = true, pty = true })
|
||||
a.nvim_set_option_value("number", false, { buf = bufnr })
|
||||
else
|
||||
@ -87,6 +87,7 @@ telescope.setup {
|
||||
telescope.load_extension('file_browser')
|
||||
telescope.load_extension('projects')
|
||||
telescope.load_extension('fzf')
|
||||
telescope.load_extension('harpoon')
|
||||
|
||||
a.nvim_create_autocmd('User', {
|
||||
pattern = 'TelescopePreviewerLoaded',
|
||||
|
@ -11,6 +11,17 @@ local highlight = function(group, opts, space)
|
||||
end
|
||||
end
|
||||
|
||||
local function cpyhl(hlgroup)
|
||||
local ok, hl = pcall(vim.api.nvim_get_hl_by_name, hlgroup, true)
|
||||
if not ok then return end
|
||||
for _, key in pairs({"foreground", "background", "special"}) do
|
||||
if hl[key] then
|
||||
hl[key] = string.format("#%06x", hl[key])
|
||||
end
|
||||
end
|
||||
return hl
|
||||
end
|
||||
|
||||
local function getcolor(index, fallback)
|
||||
return vim.g['terminal_color_' .. index] or fallback
|
||||
end
|
||||
@ -36,31 +47,15 @@ local colors = {
|
||||
|
||||
if pcall(require, "mellow") then c = require('mellow.colors').dark end
|
||||
|
||||
-- vim highlights -------------------------------------------------------------
|
||||
highlight('CursorLineNr', { bold = true })
|
||||
|
||||
-- remove tildas
|
||||
highlight('EndOfBuffer', { fg = vim.g.terminal_color_background })
|
||||
|
||||
-- make all backgrounds the same color
|
||||
highlight('NormalNC', cpyhl('Normal'))
|
||||
|
||||
-- plugin highlights ----------------------------------------------------------
|
||||
-- telescope
|
||||
highlight('TelescopeMatching', { bg = c.gray01, fg = c.blue })
|
||||
|
||||
highlight('TelescopePreviewBorder', { bg = c.bg_dark })
|
||||
highlight('TelescopePreviewNormal', { bg = c.bg_dark })
|
||||
highlight('TelescopePreviewTitle', { bg = c.bg_dark, fg = c.bg_dark })
|
||||
|
||||
highlight('TelescopePromptBorder', { bg = c.gray01 })
|
||||
highlight('TelescopePromptNormal', { bg = c.gray01 })
|
||||
highlight('TelescopePromptPrefix', { bg = c.gray01 })
|
||||
highlight('TelescopePromptTitle', { bg = c.gray01 })
|
||||
|
||||
highlight('TelescopeResultsBorder', { bg = c.bg_dark })
|
||||
highlight('TelescopeResultsNormal', { bg = c.bg_dark })
|
||||
highlight('TelescopeResultsTitle', { bg = c.bg_dark, fg = c.bg_dark })
|
||||
|
||||
highlight('TelescopeSelection', { bg = vim.g.terminal_color_background })
|
||||
highlight('TelescopeSelectionCaret', { bg = vim.g.terminal_color_background, fg = c.cyan, bold = true })
|
||||
highlight('TelescopeMatching', { fg = c.yellow })
|
||||
|
||||
-- alpha
|
||||
highlight('AlphaHeader', { fg = colors.blue })
|
||||
|
9
init.lua
9
init.lua
@ -9,15 +9,14 @@ vim.loader.enable()
|
||||
|
||||
-- main lua files -------------------------------------------------------------
|
||||
misc = require('core.misc')
|
||||
require('bootstrap')
|
||||
require('conf')
|
||||
|
||||
misc.include('bootstrap')
|
||||
misc.include('conf')
|
||||
-- core lua files -------------------------------------------------------------
|
||||
require('core.conf')
|
||||
misc.include('core.conf')
|
||||
|
||||
-- call all snippets in the lua/snippets directory ----------------------------
|
||||
if pcall(require, "luasnip") then
|
||||
require('snippet.shorthands')
|
||||
misc.include('snippet.shorthands')
|
||||
for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua/snippet',
|
||||
[[v:val =~ '\.lua$']])) do
|
||||
require('snippet.'..file:gsub('%.lua$', ''))
|
||||
|
@ -93,15 +93,8 @@ if pcall(require, "telescope") then
|
||||
-- search for vim options
|
||||
map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' })
|
||||
-- search for string in project
|
||||
map('n', '<leader>sp', function()
|
||||
vim.ui.input({ prompt = 'Find string in project' }, function(input)
|
||||
if not input or input == '' then
|
||||
vim.notify('No query!', vim.log.levels.WARN, { title = misc.appid })
|
||||
return nil
|
||||
end
|
||||
telebuilt.grep_string({ search = input })
|
||||
end)
|
||||
end, { desc = 'Find string in project.' })
|
||||
map('n', '<leader>sp', telebuilt.live_grep, { desc = 'Find string in project.' })
|
||||
|
||||
-- Code Actions (requires telescope)
|
||||
if pcall(require, "actions-preview") then
|
||||
map({ "n", "v" }, "<leader>ca", require("actions-preview").code_actions, {
|
||||
@ -110,6 +103,24 @@ if pcall(require, "telescope") then
|
||||
end
|
||||
end
|
||||
|
||||
-- harpoon
|
||||
if pcall(require, 'harpoon') then
|
||||
local mark = require("harpoon.mark")
|
||||
local ui = require("harpoon.ui")
|
||||
|
||||
map("n", "<leader>a", function()
|
||||
mark.add_file()
|
||||
vim.notify('added new file to quickmarks', vim.log.levels.INFO, {
|
||||
title = misc.appid,
|
||||
})
|
||||
end)
|
||||
map("n", "<C-e>", ui.toggle_quick_menu)
|
||||
map('n', '<C-q>', function() ui.nav_file(1) end)
|
||||
map('n', '<C-g>', function() ui.nav_file(2) end)
|
||||
map('n', '<C-h>', function() ui.nav_file(3) end)
|
||||
map('n', '<C-i>', function() ui.nav_file(4) end)
|
||||
end
|
||||
|
||||
map('n', '<leader>u', '<cmd>UndotreeToggle<CR>', { desc = 'Open undo tree.' })
|
||||
map('n', '<leader>f', '<cmd>SFMToggle<CR>', { desc = 'Open file tree view.' })
|
||||
map('n', '<leader>b', '<cmd>JABSOpen<CR>', { desc = 'Switch between buffers.' })
|
||||
@ -119,10 +130,6 @@ if pcall(require, "smart-splits") then
|
||||
map('n', '<leader>r', smartsplits.start_resize_mode)
|
||||
end
|
||||
|
||||
-- toggle term (don't use leader key in these binds)
|
||||
map({'n', 't'}, '<C-\\>', '<cmd>ToggleTerm direction=float<CR>')
|
||||
map({'n', 't'}, '<C-g>', '<cmd>lua _glow()<CR>')
|
||||
|
||||
-- git
|
||||
map('n', '<leader>gp', '<cmd>Gitsigns preview_hunk_inline<CR>')
|
||||
map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
|
||||
|
@ -36,6 +36,7 @@ misc.colorscheme('mellow')
|
||||
-- better editing -------------------------------------------------------------
|
||||
o.clipboard = 'unnamedplus' -- system clipboard
|
||||
o.splitkeep = "screen" -- keep same text on screen when spliting
|
||||
o.updatetime = 200
|
||||
|
||||
-- file saving ----------------------------------------------------------------
|
||||
o.swapfile = false
|
||||
|
@ -7,7 +7,7 @@ require('dep') {
|
||||
},
|
||||
|
||||
-- colorschemes -------------------------------------------------------------
|
||||
{ 'kvrohit/mellow.nvim',
|
||||
{ 'mellow-theme/mellow.nvim',
|
||||
requires = 'nvim-treesitter/nvim-treesitter'
|
||||
},
|
||||
|
||||
@ -32,17 +32,19 @@ require('dep') {
|
||||
|
||||
-- functional plugins -------------------------------------------------------
|
||||
{ 'lewis6991/gitsigns.nvim' }, -- very helpful git things
|
||||
{ 'squibid/git-yodel', -- git cache diff preview when in commit buffer
|
||||
url = 'https://git.squi.bid/git-yodel',
|
||||
},
|
||||
{ 'chentoast/marks.nvim' }, -- marks in gutter
|
||||
{ 'vidocqh/auto-indent.nvim' }, -- better tabbing into indents
|
||||
{ 'mbbill/undotree' }, -- careful this one is written in vimscript
|
||||
{ 'dhruvasagar/vim-table-mode' }, -- same with this one
|
||||
{ 'windwp/nvim-autopairs' },
|
||||
{ 'altermo/ultimate-autopair.nvim', -- autopairs
|
||||
branch = 'v0.6'
|
||||
},
|
||||
{ 'numToStr/Comment.nvim' },
|
||||
{ 'ahmedkhalf/project.nvim' }, -- cd into root of project
|
||||
{ 'mrjones2014/smart-splits.nvim'}, -- buffer resizing
|
||||
{ 'ThePrimeagen/harpoon', -- super duper fast navigation through files
|
||||
requires = 'nvim-lua/plenary.nvim'
|
||||
},
|
||||
|
||||
-- note taking --------------------------------------------------------------
|
||||
{ 'nvim-neorg/neorg',
|
||||
@ -82,7 +84,6 @@ require('dep') {
|
||||
-- treesitter + colorizing --------------------------------------------------
|
||||
{ 'nvim-treesitter/nvim-treesitter',
|
||||
deps = {
|
||||
'm-demare/hlargs.nvim',
|
||||
'Wansmer/treesj',
|
||||
'nvim-treesitter/nvim-treesitter-context'
|
||||
}
|
||||
@ -98,19 +99,20 @@ require('dep') {
|
||||
'lukas-reineke/cmp-under-comparator', -- better results
|
||||
'hrsh7th/cmp-buffer', -- buffers
|
||||
'FelipeLema/cmp-async-path', -- path
|
||||
'hrsh7th/cmp-calc', -- calculator
|
||||
'hrsh7th/cmp-nvim-lsp', -- lsp
|
||||
'uga-rosa/cmp-dictionary', -- dictionary
|
||||
'hrsh7th/cmp-nvim-lua', -- nvim lua api
|
||||
{ 'doxnit/cmp-luasnip-choice', -- luasnip
|
||||
requires = 'L3MON4D3/LuaSnip'
|
||||
requires = 'L3MON4D3/LuaSnip',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
-- snippets -----------------------------------------------------------------
|
||||
{ 'L3MON4D3/LuaSnip',
|
||||
deps = 'rafamadriz/friendly-snippets'
|
||||
deps = 'rafamadriz/friendly-snippets',
|
||||
config = function()
|
||||
vim.cmd('make install_jsregexp')
|
||||
end
|
||||
},
|
||||
|
||||
-- lsp ----------------------------------------------------------------------
|
||||
|
@ -13,7 +13,7 @@ end
|
||||
|
||||
function M.include(fn)
|
||||
if not pcall(require, fn) then
|
||||
vim.notify('Could not find '..fn, vim.log.levels.WARN, { title = M.appid })
|
||||
vim.notify('Could not find "'..fn, vim.log.levels.WARN..'"', { title = M.appid })
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user