1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 18:38:00 +00:00

Add neovim dotfiles

This commit is contained in:
Daniel Carrillo 2022-10-01 13:46:18 +02:00
parent b136026491
commit 4b791cb985
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
41 changed files with 1330 additions and 113 deletions

View File

@ -1,64 +0,0 @@
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
env:
TERM: xterm-256color
# LANG: "en_US.UTF-8"
# LC_CTYPE: en_US.UTF-8
shell:
program: /bin/zsh
args:
- -l
- -c
- "tmux attach || tmux"
window:
dimensions:
columns: 150
lines: 35
position:
x: 1200
y: 510
scrolling:
history: 50000
cursor:
style: Underline
selection:
semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
font:
normal:
family: "Roboto Mono"
style: Regular
size: 9.0
use_thin_strokes: true
colors:
primary:
background: '#073642'
foreground: '#BABABA'
normal:
black: '#000000'
red: '#E8341C'
green: '#68C256'
yellow: '#F2D42C'
blue: '#1C98E8'
magenta: '#8E69C9'
cyan: '#1C98E8'
white: '#BABABA'
bright:
black: '#666666'
red: '#E05A4F'
green: '#77B869'
yellow: '#EFD64B'
blue: '#387CD3'
magenta: '#957BBE'
cyan: '#3D97E2'
white: '#BABABA'

View File

@ -37,9 +37,10 @@ enable_audio_bell no
enabled_layouts vertical,fat,grid,horizontal,splits,stack,tall enabled_layouts vertical,fat,grid,horizontal,splits,stack,tall
# resize_in_steps yes
remember_window_size no remember_window_size no
initial_window_width 2100 initial_window_width 2110
initial_window_height 1150 initial_window_height 1160
window_padding_width 1 window_padding_width 1
active_border_color #C0C0C0 active_border_color #C0C0C0
@ -47,40 +48,49 @@ active_border_color #C0C0C0
#: Color scheme {{{ #: Color scheme {{{
foreground #BABABA ## name: Tokyo Night
background #073642 ## license: MIT
## author: Folke Lemaitre
## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_night.conf
#: black background #24283b
color0 #000000 foreground #c0caf5
color8 #666666 selection_background #33467c
selection_foreground #c0caf5
url_color #73daca
cursor #c0caf5
cursor_text_color #1a1b26
#: red # Tabs
color1 #E8341C active_tab_background #7aa2f7
color9 #E05A4F active_tab_foreground #16161e
inactive_tab_background #292e42
inactive_tab_foreground #545c7e
#tab_bar_background #15161e
#: green # normal
color2 #68C256 color0 #15161e
color10 #77B869 color1 #f7768e
color2 #9ece6a
color3 #e0af68
color4 #7aa2f7
color5 #bb9af7
color6 #7dcfff
color7 #a9b1d6
#: yellow # bright
color3 #F2D42C color8 #414868
color11 #EFD64B color9 #f7768e
color10 #9ece6a
color11 #e0af68
color12 #7aa2f7
color13 #bb9af7
color14 #7dcfff
color15 #c0caf5
#: blue # extended colors
color4 #1C98E8 color16 #ff9e64
color12 #387CD3 color17 #db4b4b
#: magenta
color5 #8E69C9
color13 #957BBE
#: cyan
color6 #1C98E8
color14 #3D97E2
#: white
color7 #BABABA
color15 #BABABA
#: }}} #: }}}

3
.config/nvim/README.md Normal file
View File

@ -0,0 +1,3 @@
# Neovim configuration files
Neovim conf heavily adapted to suit my needs, based on LunarVim's [basic ide](https://github.com/LunarVim/nvim-basic-ide).

27
.config/nvim/init.lua Normal file
View File

@ -0,0 +1,27 @@
require("user.options")
require("user.keymaps")
require("user.plugins")
require("user.autocommands")
require("user.commands")
require("user.colorscheme")
require("user.cmp")
require("user.telescope")
require("user.treesitter")
require("user.autopairs")
require("user.comment")
require("user.gitsigns")
require("user.neo-tree")
require("user.bufferline")
require("user.lualine")
require("user.impatient")
require("user.illuminate")
require("user.indentline")
require("user.lsp")
require("user.dap")
require("user.go")
require("user.wilder")
require("user.trouble")
require("user.autosave")
require("user.markdowntoc")
require("user.session-manager")
require("user.diffview")

View File

@ -0,0 +1,45 @@
vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif")
-- Fixes Autocomment
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
callback = function()
vim.cmd("set formatoptions-=cro")
end,
})
-- Highlight Yanked Text
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
end,
})
-- Set options by FileType
-- Set wrap and spell in markdown and gitcommit
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Set wrap and spell in markdown and gitcommit
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "go", "makefile", "lua" },
callback = function()
vim.opt_local.expandtab = false
end,
})
-- Use 'q' to quit from common plugins
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" },
callback = function()
vim.cmd([[
nnoremap <silent> <buffer> q :close<CR>
set nobuflisted
]])
end,
})

View File

@ -0,0 +1,17 @@
-- Setup nvim-cmp.
local status_ok, npairs = pcall(require, "nvim-autopairs")
if not status_ok then
return
end
npairs.setup({
check_ts = true, -- treesitter integration
disable_filetype = { "TelescopePrompt" },
})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({}))

View File

@ -0,0 +1,12 @@
local status_ok, autosave = pcall(require, "autosave")
if not status_ok then
return
end
autosave.setup({
execution_message = {
message = function()
return ""
end,
},
})

View File

@ -0,0 +1,92 @@
local status_ok, bufferline = pcall(require, "bufferline")
if not status_ok then
return
end
bufferline.setup({
options = {
close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
offsets = { { filetype = "neo-tree", text = "", padding = 1 } },
separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' },
},
highlights = {
fill = {
fg = { attribute = "fg", highlight = "#ff0000" },
bg = { attribute = "bg", highlight = "TabLine" },
},
background = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
buffer_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
close_button = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
close_button_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
tab_selected = {
fg = { attribute = "fg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
tab = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
tab_close = {
fg = { attribute = "fg", highlight = "TabLineSel" },
bg = { attribute = "bg", highlight = "Normal" },
},
duplicate_selected = {
fg = { attribute = "fg", highlight = "TabLineSel" },
bg = { attribute = "bg", highlight = "TabLineSel" },
italic = true,
},
duplicate_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
italic = true,
},
duplicate = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
italic = true,
},
modified = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
modified_selected = {
fg = { attribute = "fg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
modified_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
separator = {
fg = { attribute = "bg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
separator_selected = {
fg = { attribute = "bg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
indicator_selected = {
fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" },
bg = { attribute = "bg", highlight = "Normal" },
},
},
})

View File

@ -0,0 +1,128 @@
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
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = kind_icons[vim_item.kind]
vim_item.menu = ({
nvim_lsp = "",
nvim_lua = "",
luasnip = "",
buffer = "",
path = "",
emoji = "",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
experimental = {
ghost_text = true,
},
})

View File

@ -0,0 +1,21 @@
local colorscheme = "tokyonight"
-- if colorscheme == "nightfox" then
-- local status_nf_ok, nightfox = pcall(require, "nightfox")
-- if not status_nf_ok then
-- return
-- end
--
-- local palettes = {
-- nightfox = {
-- bg1 = "#24283b",
-- },
-- }
--
-- nightfox.setup({ palettes = palettes })
-- end
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
return
end

View File

@ -0,0 +1,15 @@
vim.api.nvim_create_user_command("CopyBufferPath", function()
local path = vim.fn.expand("%:p")
vim.fn.setreg("+", path)
vim.notify('Copied "' .. path .. '" to the clipboard!')
end, {})
vim.api.nvim_create_user_command("CopyDirectoryPath", function()
local path = vim.fn.expand("%:p:h")
vim.fn.setreg("+", path)
vim.notify('Copied "' .. path .. '" to the clipboard!')
end, {})
vim.api.nvim_create_user_command("RemoveTrailingSpaces", function()
vim.cmd("% s/\\s\\+$//e")
end, {})

View File

@ -0,0 +1,22 @@
local status_ok, comment = pcall(require, "Comment")
if not status_ok then
return
end
comment.setup({
pre_hook = function(ctx)
local U = require("Comment.utils")
local location = nil
if ctx.ctype == U.ctype.block then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
end
return require("ts_context_commentstring.internal").calculate_commentstring({
key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
location = location,
})
end,
})

View File

@ -0,0 +1,50 @@
local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then
return
end
local dap_ui_status_ok, dapui = pcall(require, "dapui")
if not dap_ui_status_ok then
return
end
local dap_install_status_ok, dap_install = pcall(require, "dap-install")
if not dap_install_status_ok then
return
end
dap_install.setup({})
dap_install.config("python", {})
-- add other configs here
dapui.setup({})
-- deprecated
-- sidebar = {
-- elements = {
-- {
-- id = "scopes",
-- size = 0.25, -- Can be float or integer > 1
-- },
-- { id = "breakpoints", size = 0.25 },
-- },
-- size = 40,
-- position = "right", -- Can be "left", "right", "top", "bottom"
-- },
-- tray = {
-- elements = {},
-- },
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
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

View File

@ -0,0 +1,8 @@
local status_ok, diffview = pcall(require, "diffview")
if not status_ok then
return
end
diffview.setup({})
vim.opt.fillchars = "diff: "

View File

@ -0,0 +1,14 @@
local status_ok, gitsigns = pcall(require, "gitsigns")
if not status_ok then
return
end
gitsigns.setup({
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
delete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
topdelete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
changedelete = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
},
})

View File

@ -0,0 +1,9 @@
local status_ok, go = pcall(require, "go")
if not status_ok then
return
end
vim.cmd("autocmd FileType go nmap <Leader>gf :lua require('go.format').goimport()<CR>")
go.setup({
icons = { breakpoint = "", currentpos = "🏃" },
})

View File

@ -0,0 +1,8 @@
vim.g.Illuminate_ftblacklist = { "neo-tree" }
vim.api.nvim_set_keymap("n", "<a-n>", '<cmd>lua require"illuminate".next_reference{wrap=true}<cr>', { noremap = true })
vim.api.nvim_set_keymap(
"n",
"<a-p>",
'<cmd>lua require"illuminate".next_reference{reverse=true,wrap=true}<cr>',
{ noremap = true }
)

View File

@ -0,0 +1,6 @@
local status_ok, impatient = pcall(require, "impatient")
if not status_ok then
return
end
impatient.enable_profile()

View File

@ -0,0 +1,18 @@
local status_ok, indent_blankline = pcall(require, "indent_blankline")
if not status_ok then
return
end
indent_blankline.setup({
char = "",
show_trailing_blankline_indent = false,
show_first_indent_level = true,
use_treesitter = true,
show_current_context = true,
buftype_exclude = { "terminal", "nofile" },
filetype_exclude = {
"help",
"packer",
"NvimTree",
},
})

View File

@ -0,0 +1,89 @@
-- Shorten function name
local keymap = vim.keymap.set
-- Silent keymap option
local opts = { silent = true }
--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
-- Modes
-- normal_mode = "n",
-- insert_mode = "i",
-- visual_mode = "v",
-- visual_block_mode = "x",
-- term_mode = "t",
-- command_mode = "c",
-- Normal --
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)
-- Resize with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
-- Navigate buffers
keymap("n", "<S-l>", ":bnext<CR>", opts)
keymap("n", "<S-h>", ":bprevious<CR>", opts)
-- Clear highlights
keymap("n", "<leader>h", "<cmd>nohlsearch<CR>", opts)
-- Close buffers
keymap("n", "<S-q>", "<cmd>Bdelete!<CR>", opts)
-- Toogle Trouble
keymap("n", "<leader>xx", "<cmd>TroubleToggle<cr>", opts)
keymap("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>", opts)
keymap("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>", opts)
keymap("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>", opts)
keymap("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>", opts)
keymap("n", "gR", "<cmd>TroubleToggle lsp_references<cr>", opts)
-- Better paste
keymap("v", "p", '"_dP', opts)
-- Insert --
-- Press jk fast to enter
keymap("i", "jk", "<ESC>", opts)
-- Visual --
-- Stay in indent mode
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- NeoTree
keymap("n", "<leader>e", ":Neotree toggle<CR>", opts)
keymap("n", "<leader>gg", ":Neotree float git_status<CR>", opts)
-- Telescope
keymap("n", "<leader>ff", ":Telescope find_files<CR>", opts)
keymap("n", "<C-p>", ":Telescope find_files<CR>", opts)
keymap("n", "<leader>fg", ":Telescope live_grep<CR>", opts)
keymap("n", "<leader>fb", ":Telescope buffers<CR>", opts)
-- Comment
keymap("n", "<leader>/", "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", opts)
keymap("x", "<leader>/", '<ESC><CMD>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<CR>')
-- DAP
keymap("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)
keymap("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", opts)
keymap("n", "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", opts)
keymap("n", "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", opts)
keymap("n", "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>", opts)
keymap("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts)
keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts)
keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
keymap("n", "<leader>dt", "<cmd>lua require'dap'.terminate()<cr>", opts)
-- Session Manager
keymap("n", "<leader>so", ":SessionManager load_session<cr>", opts)
keymap("n", "<leader>sd", ":SessionManager delete_session<cr>", opts)
keymap("n", "<leader>ss", ":SessionManager save_current_session<cr>", opts)

View File

@ -0,0 +1,91 @@
local M = {}
local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_cmp_ok then
return
end
M.capabilities = vim.lsp.protocol.make_client_capabilities()
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities)
M.setup = function()
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
local config = {
virtual_text = false, -- disable virtual text
signs = {
active = signs, -- show signs
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
end
local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_buf_set_keymap
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<cr>", opts)
-- keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
-- keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
end
M.on_attach = function(client, bufnr)
if client.name == "tsserver" then
client.resolved_capabilities.document_formatting = false
end
if client.name == "sumneko_lua" then
client.resolved_capabilities.document_formatting = false
end
lsp_keymaps(bufnr)
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then
return
end
illuminate.on_attach(client)
end
return M

View File

@ -0,0 +1,8 @@
local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then
return
end
require("user.lsp.lsp-installer")
require("user.lsp.handlers").setup()
require("user.lsp.null-ls")

View File

@ -0,0 +1,46 @@
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
return
end
local servers = {
"sumneko_lua",
-- "cssls",
-- "html",
-- "tsserver",
"gopls",
-- "grammarly",
"golangci_lint_ls",
"pyright",
"bashls",
"jsonls",
"yamlls",
}
lsp_installer.setup()
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status_ok then
return
end
local opts = {}
for _, server in pairs(servers) do
opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
}
if server == "sumneko_lua" then
local sumneko_opts = require("user.lsp.settings.sumneko_lua")
opts = vim.tbl_deep_extend("force", sumneko_opts, opts)
end
if server == "pyright" then
local pyright_opts = require("user.lsp.settings.pyright")
opts = vim.tbl_deep_extend("force", pyright_opts, opts)
end
lspconfig[server].setup(opts)
end

View File

@ -0,0 +1,29 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics
-- https://github.com/prettier-solidity/prettier-plugin-solidity
null_ls.setup({
debug = false,
sources = {
formatting.prettier.with({
extra_filetypes = { "toml" },
extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
}),
formatting.black.with({ extra_args = { "--fast" } }),
formatting.stylua,
diagnostics.golangci_lint.with({ extra_args = { "--fast" } }),
diagnostics.flake8.with({
extra_args = { "--max-line-length=120" },
}),
diagnostics.cfn_lint,
diagnostics.shellcheck,
diagnostics.hadolint,
},
})

View File

@ -0,0 +1,9 @@
return {
settings = {
python = {
analysis = {
typeCheckingMode = "off",
},
},
},
}

View File

@ -0,0 +1,18 @@
return {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
telemetry = {
enable = false,
},
},
},
}

View File

@ -0,0 +1,73 @@
local status_ok, lualine = pcall(require, "lualine")
if not status_ok then
return
end
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
symbols = { error = "", warn = "" },
colored = false,
always_visible = true,
}
local diff = {
"diff",
colored = false,
symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols
cond = hide_in_width,
}
local filetype = {
"filetype",
icons_enabled = false,
}
local location = {
"location",
padding = 0,
}
local spaces = function()
return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local gitblame_status_ok, gitblame = pcall(require, "gitblame")
if not gitblame_status_ok then
return
end
vim.g.gitblame_date_format = "%r"
vim.g.gitblame_display_virtual_text = 0
vim.g.gitblame_message_template = "<author>, <date>"
lualine.setup({
options = {
globalstatus = true,
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = { "alpha", "dashboard" },
always_divide_middle = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch" },
lualine_c = { diagnostics, { "filename", path = 3 } },
lualine_x = {
{ gitblame.get_current_blame_text, cond = gitblame.is_blame_text_available },
diff,
spaces,
"encoding",
filetype,
},
lualine_y = { location },
lualine_z = { "progress" },
},
})

View File

@ -0,0 +1,3 @@
vim.g.vmt_dont_insert_fence = true
vim.g.vmt_list_item_char = "-"
vim.g.vmt_include_headings_before = true

View File

@ -0,0 +1,68 @@
local status_ok, neotree = pcall(require, "neo-tree")
if not status_ok then
return
end
vim.g.neo_tree_remove_legacy_commands = true
neotree.setup({
popup_border_style = "rounded",
default_component_configs = {
indent = {
padding = 0,
with_expanders = false,
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "",
default = "",
},
git_status = {
symbols = {
added = "",
deleted = "",
modified = "",
renamed = "",
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
},
},
window = {
width = 40,
mappings = {
["o"] = "open",
["Z"] = "expand_all_nodes",
},
},
filesystem = {
filtered_items = {
visible = false,
hide_dotfiles = true,
hide_gitignored = false,
hide_by_name = {
"__pycache__",
},
},
follow_current_file = true,
hijack_netrw_behavior = "open_current",
use_libuv_file_watcher = true,
},
git_status = {
window = {
position = "float",
},
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function(_)
vim.opt_local.signcolumn = "auto"
end,
},
},
})

View File

@ -0,0 +1,12 @@
local status_nf_ok, nightfox = pcall(require, "nightfox")
if not status_nf_ok then
return
end
local palettes = {
nightfox = {
bg1 = "#1c1e26",
},
}
nightfox.setup({ palettes = palettes })

View File

@ -0,0 +1,44 @@
vim.opt.backup = false -- creates a backup file
vim.opt.autowriteall = true
vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard
vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages
vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp
vim.opt.conceallevel = 0 -- so that `` is visible in markdown files
vim.opt.fileencoding = "utf-8" -- the encoding written to a file
vim.opt.hlsearch = true -- highlight all matches on previous search pattern
vim.opt.ignorecase = false -- ignore case in search patterns
vim.opt.mouse = "a" -- allow the mouse to be used in neovim
vim.opt.pumheight = 10 -- pop up menu height
vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
vim.opt.showtabline = 0 -- always show tabs
vim.opt.smartcase = true -- smart case
vim.opt.smartindent = true -- make indenting smarter again
vim.opt.splitbelow = true -- force all horizontal splits to go below current window
vim.opt.splitright = true -- force all vertical splits to go to the right of current window
vim.opt.swapfile = false -- creates a swapfile
vim.opt.termguicolors = true -- set term gui colors (most terminals support this)
vim.opt.timeoutlen = 1000 -- time to wait for a mapped sequence to complete (in milliseconds)
vim.opt.undofile = true -- enable persistent undo
vim.opt.updatetime = 300 -- faster completion (4000ms default)
vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
vim.opt.cursorline = true -- highlight the current line
vim.opt.number = true -- set numbered lines
vim.opt.laststatus = 3
vim.opt.showcmd = false
vim.opt.ruler = false
-- vim.opt.cc = "80"
vim.opt.listchars = "tab: ,trail:Ç"
vim.opt.list = true
vim.opt.expandtab = true -- convert tabs to spaces
vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 4 -- insert 4 spaces for a tab
vim.opt.numberwidth = 4 -- set number column width to 2 {default 4}
vim.opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time
vim.opt.wrap = false -- display lines as one long line
vim.opt.scrolloff = 8 -- is one of my fav
vim.opt.sidescrolloff = 8
vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications
vim.opt.fillchars.eob = " "
vim.opt.shortmess:append("c")
vim.opt.whichwrap:append("<,>,[,],h,l")
vim.opt.iskeyword:append("-")

View File

@ -0,0 +1,139 @@
local fn = vim.fn
-- Automatically install packer
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
PACKER_BOOTSTRAP = fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
print("Installing packer close and reopen Neovim...")
vim.cmd([[packadd packer.nvim]])
end
-- Autocommand that reloads neovim whenever you save the plugins.lua file
-- vim.cmd([[
-- augroup packer_user_config
-- autocmd!
-- autocmd BufWritePost plugins.lua source <afile> | PackerSync
-- augroup end
-- ]])
-- Use a protected call so we don't error out on first use
local status_ok, packer = pcall(require, "packer")
if not status_ok then
return
end
-- Have packer use a popup window
packer.init({
display = {
open_fn = function()
return require("packer.util").float({ border = "rounded" })
end,
},
})
-- Install your plugins here
return packer.startup(function(use)
-- Plugins
use({ "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" })
use({ "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" })
use({ "windwp/nvim-autopairs", commit = "14cc2a4fc6243152ba085cc2059834113496c60a" })
use({ "numToStr/Comment.nvim", tag = "v0.6.1" })
use({ "JoosepAlviste/nvim-ts-context-commentstring", commit = "4d3a68c41a53add8804f471fcc49bb398fe8de08" })
use({ "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" })
use({ "akinsho/bufferline.nvim", tag = "v2.*" })
use({ "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" })
use({ "nvim-lualine/lualine.nvim", commit = "3362b28f917acc37538b1047f187ff1b5645ecdd" })
use({ "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" })
use({ "lukas-reineke/indent-blankline.nvim", tag = "v2.*" })
use({ "Pocco81/auto-save.nvim", commit = "2c7a2943340ee2a36c6a61db812418fca1f57866" })
use({ "gelguy/wilder.nvim", commit = "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" })
use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a", run = "make" })
use({ "mg979/vim-visual-multi", tag = "v0.*" })
use({ "Shatur/neovim-session-manager", commit = "4005dac93f5cd1257792259ef4df6af0e3afc213" })
use({ "nvim-treesitter/nvim-treesitter", commit = "aebc6cf6bd4675ac86629f516d612ad5288f7868" })
use({
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = { "MunifTanjim/nui.nvim", commit = "e9889bbd9919544697d497537acacd9c67d0de99" },
})
-- Colorschemes
use({ "folke/tokyonight.nvim", commit = "4092905fc570a721128af73f6bf78e5d47f5edce" })
use({ "EdenEast/nightfox.nvim", commit = "59c3dbcec362eff7794f1cb576d56fd8a3f2c8bb" })
-- cmp plugins
use({ "hrsh7th/nvim-cmp", commit = "2427d06b6508489547cd30b6e86b1c75df363411" })
use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" })
use({ "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" })
use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" })
use({ "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" })
use({ "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" })
-- snippets
use({ "L3MON4D3/LuaSnip", tag = "v1.*" })
use({ "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" })
-- LSP
use({ "neovim/nvim-lspconfig", commit = "af43c300d4134db3550089cd4df6c257e3734689" })
use({ "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" })
use({ "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" })
use({ "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" })
use({ "folke/trouble.nvim", commit = "929315ea5f146f1ce0e784c76c943ece6f36d786" })
-- Telescope
use({ "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" })
use({ "nvim-telescope/telescope-ui-select.nvim", commit = "62ea5e58c7bbe191297b983a9e7e89420f581369" })
use({
"nvim-telescope/telescope-fzf-native.nvim",
commit = "65c0ee3d4bb9cb696e262bca1ea5e9af3938fc90",
run = "make",
})
-- Git
use({ "lewis6991/gitsigns.nvim", tag = "v0.5*" })
use({ "sindrets/diffview.nvim", commit = "6baa30d0a6f63da254c2d2c0638a426166973976" })
use({ "f-person/git-blame.nvim", commit = "08e75b7061f4a654ef62b0cac43a9015c87744a2" })
-- DAP
use({ "mfussenegger/nvim-dap", tag = "0.3*" })
use({ "rcarriga/nvim-dap-ui", tag = "v2.*" })
use({ "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" })
use({ "theHamsta/nvim-dap-virtual-text", commit = "2971ce3e89b1711cc26e27f73d3f854b559a77d4" })
-- golang
use({ "ray-x/go.nvim", commit = "24270e540b96bcd6c0c8184532b93a5d4a55c38b" })
use({
"ray-x/guihua.lua",
commit = "baebba3ba0e621eb04f5ac32a946935fdf5f5b87",
run = "cd lua/fzy && make",
config = function()
require("guihua.maps").setup({
maps = { close_view = "<C-x>" },
})
end,
})
-- markdown
use({ "mzlogin/vim-markdown-toc", commit = "7ec05df27b4922830ace2246de36ac7e53bea1db" })
use({
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
setup = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
})
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)

View File

@ -0,0 +1,8 @@
local status_ok, session_manager = pcall(require, "session_manager")
if not status_ok then
return
end
session_manager.setup({
autosave_only_in_session = false,
})

View File

@ -0,0 +1,42 @@
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
local actions = require("telescope.actions")
telescope.setup({
defaults = {
prompt_prefix = "> ",
selection_caret = "",
path_display = { "smart" },
file_ignore_patterns = { ".git/", "node_modules" },
mappings = {
i = {
["<Down>"] = actions.cycle_history_next,
["<Up>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
},
pickers = {
live_grep = {
additional_args = function()
return { "--hidden", "-g", "!.git/" }
end,
},
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
fzf = {
case_mode = "ignore_case",
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("ui-select")

View File

@ -0,0 +1,17 @@
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
configs.setup({
ensure_installed = "all", -- one of "all" or a list of languages
ignore_install = { "" }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = { "css" }, -- list of language that will be disabled
},
autopairs = {
enable = true,
},
indent = { enable = true, disable = { "python", "css" } },
})

View File

@ -0,0 +1,6 @@
local status_ok, trouble = pcall(require, "trouble")
if not status_ok then
return
end
trouble.setup({})

View File

@ -0,0 +1,67 @@
local status_ok, wilder = pcall(require, "wilder")
if not status_ok then
return
end
wilder.setup({
modes = { ":" },
})
wilder.set_option("use_python_remote_plugin", 1)
wilder.set_option("pipeline", {
wilder.branch(
wilder.python_file_finder_pipeline({
file_command = { "fd", "--hidden", "--type=file", "--exclude=.git" },
dir_command = { "fd", "--hidden", "--type=directory", "--exclude=.git" },
filters = { "fuzzy_filter", "difflib_sorter" },
}),
wilder.cmdline_pipeline({
fuzzy = 2,
fuzzy_filter = wilder.lua_fzy_filter(),
})
),
})
-- Better highlighting
local gradient = {
"#f4468f",
"#fd4a85",
"#ff507a",
"#ff566f",
"#ff5e63",
"#ff6658",
"#ff704e",
"#ff7a45",
"#ff843d",
"#ff9036",
"#f89b31",
"#efa72f",
"#e6b32e",
"#dcbe30",
"#d2c934",
"#c8d43a",
"#bfde43",
"#b6e84e",
"#aff05b",
}
for i, fg in ipairs(gradient) do
gradient[i] = wilder.make_hl("WilderGradient" .. i, "Pmenu", { { a = 1 }, { a = 1 }, { foreground = fg } })
end
wilder.set_option(
"renderer",
wilder.popupmenu_renderer({
highlights = {
border = "Normal",
gradient = gradient,
},
border = "rounded",
highlighter = wilder.highlighter_with_gradient({
wilder.lua_fzy_highlighter(),
}),
})
)

View File

@ -48,9 +48,9 @@ get_icon_by_name()
{ {
name=$(echo "$1" | tr '[:upper:]' '[:lower:]') name=$(echo "$1" | tr '[:upper:]' '[:lower:]')
declare -A ICON_MAP=( declare -A ICON_MAP=(
[tilix]=
[alacritty]= [alacritty]=
[kitty]= [kitty]=
[nvim]=
[code]= [code]=
[brave-browser]= [brave-browser]=
[firefox]= [firefox]=
@ -76,6 +76,7 @@ get_icon_by_name()
[spotify]= [spotify]=
[telegramdesktop]= [telegramdesktop]=
[xterm]= [xterm]=
[tilix]=
) )
if [ ${ICON_MAP[$name]+_} ]; then if [ ${ICON_MAP[$name]+_} ]; then
@ -191,7 +192,7 @@ generate_window_list() {
# Format each window name one by one # Format each window name one by one
# Space and . are both used as IFS, # Space and . are both used as IFS,
# because classname and class are separated by '.' # because classname and class are separated by '.'
while IFS=" " read -r wid ws cname host title; do while IFS=" " read -r wid ws cname _ title; do
cname=${cname##*.} cname=${cname##*.}
# Don't show the window if on another workspace (-1 = sticky) # Don't show the window if on another workspace (-1 = sticky)
if [ "$ws" != "$active_workspace" ] && [ "$ws" != "-1" ]; then if [ "$ws" != "$active_workspace" ] && [ "$ws" != "-1" ]; then

14
.vimrc
View File

@ -1,14 +0,0 @@
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
syntax on
" Use four spaces for indentation
set tabstop=4
set shiftwidth=4
set expandtab
" Disable visual mode
set mouse-=a
let mapleader=","

6
.zshrc
View File

@ -42,6 +42,8 @@ alias k=kubectl
alias icat="kitty +kitten icat --align=left" alias icat="kitty +kitten icat --align=left"
alias idiff="kitty +kitten diff" alias idiff="kitty +kitten diff"
alias ls="ls --group-directories-first --color=auto --hyperlink=auto" alias ls="ls --group-directories-first --color=auto --hyperlink=auto"
alias vim=nvim
alias neovim=nvim
##### Functions to be used from command line ##### ##### Functions to be used from command line #####
@ -79,8 +81,8 @@ fi
##### default apps ##### ##### default apps #####
export EDITOR='vim' export EDITOR='nvim'
export VISUAL='vim' export VISUAL='nvim'
export PAGER='less' export PAGER='less'
export BROWSER='/usr/bin/vivaldi-stable' export BROWSER='/usr/bin/vivaldi-stable'

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# Dot Files
My dotfiles, including:
- neovim
- kitty
- polybar
- zsh
- prezto conf for my [prezto fork](https://github.com/dcarrillo/prezto)
- p10k
Unmaintained because I don't use them anymore:
- tmux
- tilix (dconf)
In addition to the dotfiles, some Gnome shell extension confs are included to make polybar and cli great again on Gnome.