Initial commit for public dots

This commit is contained in:
2023-07-08 15:20:41 +03:00
commit 2c53e85568
74 changed files with 5096 additions and 0 deletions

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

@ -0,0 +1,9 @@
_G.load = function(file)
require("plenary.reload").reload_module(file, true)
return require(file)
end
require("plugins")
load("options")
load("mappings")
load("disablebuiltin")

View File

@ -0,0 +1,24 @@
local disabled_built_ins = {
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"gzip",
"zip",
"zipPlugin",
"tar",
"tarPlugin",
"getscript",
"getscriptPlugin",
"vimball",
"vimballPlugin",
"2html_plugin",
"logipat",
"rrhelper",
"spellfile_plugin",
"matchit"
}
for _, plugin in pairs(disabled_built_ins) do
vim.g["loaded_" .. plugin] = 1
end

View File

@ -0,0 +1,111 @@
local function map(mode, lhs, rhs, opts)
local options = {noremap = false}
if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
local function noremap(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- leader
vim.g.mapleader = ' '
-- visual block indenting
noremap('v', '<', '<gv')
noremap('v', '>', '>gv')
-- centered cursor
noremap('n', 'n', 'nzz')
noremap('n', 'N', 'Nzz')
noremap('n', 'J', 'mzJ`z')
-- escape terminal mode
noremap('t', '<Esc>', '<C-\\><C-n>')
-- newline without entering insert mode
noremap('n', '<C-J>', 'o<Esc>')
noremap('n', '<C-K>', 'O<Esc>')
-- movement
noremap('n', '<leader>h', ':wincmd h<cr>')
noremap('n', '<leader>j', ':wincmd j<cr>')
noremap('n', '<leader>k', ':wincmd k<cr>')
noremap('n', '<leader>l', ':wincmd l<cr>')
-- splits and buffers
noremap('n', '<leader>sv', ':vsplit<CR>')
noremap('n', '<leader>sz', ':split<CR>')
noremap('n', '<leader>st', ':tabnew<CR>')
noremap('n', '<leader>sb', ':Telescope buffers<CR>')
noremap('n', '<leader>sh', ':tabprevious<cr>')
noremap('n', '<leader>sl', ':tabnext<cr>')
-- basics
noremap('n', '<leader>q', ':q<CR>')
noremap('n', '<leader>Q', ':qa<CR>')
noremap('n', '<leader>x', ':q!<CR>')
noremap('n', '<leader>X', ':qa!<CR>')
noremap('n', '<leader>w', ':w<CR>')
noremap('n', '<leader>W', ':wa<CR>')
noremap('n', '<leader>f', ':NvimTreeToggle<CR>')
noremap('n', '<leader>F', ':Telescope find_files<CR>')
-- toggle term
noremap('n', '<leader>c', ':ToggleTermToggleAll<CR>')
noremap('n', '<leader>C', ':ToggleTerm<CR>')
-- frequent actions
noremap('n', '<leader>ar', ':source ~/.config/nvim/init.lua<CR>')
noremap('n', '<leader>ac', ':cd ~/.config/nvim/<CR>')
-- keymap switches
noremap('n', '<leader>me', ':set keymap=<CR>')
noremap('n', '<leader>mh', ':set keymap=hebrew<CR>')
-- telescope
noremap('n', '<leader>tt', ':Telescope<CR>')
noremap('n', '<leader>tl', ':Telescope lsp_dynamic_workspace_symbols<CR>')
noremap('n', '<leader>to', ':Telescope oldfiles<CR>')
noremap('n', '<leader>tg', ':Telescope live_grep<CR>')
noremap('n', '<leader>ts', ':Telescope treesitter<CR>')
noremap('n', '<leader>tm', ':Telescope git_status<CR>')
noremap('n', '<leader>tb', ':Telescope git_branches<CR>')
noremap('n', '<leader>tc', ':Telescope git_commits<CR>')
noremap('n', '<leader>tf', ':Telescope git_files<CR>')
-- code
noremap('n', '<leader>gf', ':Neoformat<CR>')
noremap('n', '<leader>gd', ':Telescope lsp_definitions<CR>')
noremap('n', '<leader>gi', ':Telescope lsp_implementations<CR>')
noremap('n', '<leader>gr', ':Telescope lsp_references<CR>')
noremap('n', '<leader>ga', ':Telescope lsp_code_actions<CR>')
noremap('n', '<leader>gq', ':Telescope lsp_workspace_diagnostics<CR>')
noremap('n', '<leader>gD', ':lua vim.lsp.buf.declaration()<CR>')
noremap('n', '<leader>gk', ':lua vim.lsp.buf.hover()<CR>')
noremap('n', '<leader>gt', ':lua vim.lsp.buf.type_definition()<CR>')
noremap('n', '<leader>gn', ':lua vim.lsp.buf.rename()<CR>')
noremap('n', '<leader>ge', ':lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
noremap('n', '[d', ':lua vim.lsp.diagnostic.goto_prev()<CR>')
noremap('n', ']d', ':lua vim.lsp.diagnostic.goto_next()<CR>')
-- debug mappings
noremap('n', '<leader>dc', ":lua require'dap'.continue()<CR>")
noremap('n', '<leader>dn', ":lua require'dap'.step_over()<CR>")
noremap('n', '<leader>di', ":lua require'dap'.step_into()<CR>")
noremap('n', '<leader>do', ":lua require'dap'.step_out()<CR>")
noremap('n', '<leader>db', ":lua require'dap'.toggle_breakpoint()<CR>")
noremap('n', '<leader>dl', ":lua require'dap'.run_last()<CR>")
noremap('n', '<leader>dq', ":lua require'dap'.close()<CR>")
noremap('n', '<leader>dv', ':Telescope dap variables<CR>')
noremap('n', '<leader>dh', ':Telescope dap commands<CR>')
noremap('n', '<leader>dp', ':Telescope dap list_breakpoints<CR>')
noremap('n', '<leader>du', ":lua require'dapui'.toggle()<CR>")
-- vsnip jumpable mappings
map('i', '<Tab>', "vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'", {expr = true})
map('s', '<Tab>', "vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'", {expr = true})
map('i', '<S-Tab>', "vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>'", {expr = true})
map('s', '<S-Tab>', "vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>'", {expr = true})

View File

@ -0,0 +1,31 @@
local cmd = vim.cmd
local opt = vim.opt
local g = vim.g
-- sensible settings
opt.autoread = true
opt.clipboard = 'unnamedplus'
opt.conceallevel = 0
opt.hlsearch = false
opt.lazyredraw = true
opt.mouse = 'a'
opt.nu = true
opt.rnu = true
opt.scrolloff = 10
opt.shortmess = 'c'
opt.showcmd = true
opt.showmode = false
opt.sw = 4
opt.swapfile = false
opt.timeoutlen = 500
opt.ts = 4
-- opt.wrap = false
-- :FormatJson command using jq
cmd 'autocmd FileType json :command! FormatJson %!jq .'
-- trigger autoread on file change
cmd "autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif"
-- neovim-qt font
opt.guifont = 'DejaVu\\ Sans\\ Mono:h14'

View File

@ -0,0 +1,217 @@
require('packer').startup(function()
use 'wbthomason/packer.nvim'
--
-- LSP
--
-- lspconfig
use {
'neovim/nvim-lspconfig',
event = 'BufEnter',
config = function() require('plugins.lsp') end
}
-- nvim lint
use {
'mfussenegger/nvim-lint',
event = 'BufWrite',
config = function() require('plugins.lint') end
}
--
-- completion
--
-- cmp
use {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
config = function() require('plugins.cmp') end
}
use {
'hrsh7th/cmp-nvim-lsp',
after = 'nvim-cmp'
}
use {
'hrsh7th/cmp-vsnip',
after = 'nvim-cmp'
}
use {
'hrsh7th/cmp-buffer',
after = 'nvim-cmp'
}
use {
'hrsh7th/cmp-path',
after = 'nvim-cmp'
}
-- snippets
use {
'hrsh7th/vim-vsnip',
after = 'nvim-cmp'
}
use {
'rafamadriz/friendly-snippets',
after = 'vim-vsnip'
}
-- autopairs
use {
'windwp/nvim-autopairs',
after = 'nvim-cmp',
config = function() require('plugins.autopairs') end
}
-- treesitter
use {
'nvim-treesitter/nvim-treesitter',
event = 'BufEnter',
config = function() require('plugins.treesitter') end
}
-- dap
use {
'mfussenegger/nvim-dap',
module = 'dap',
config = function() require('plugins.dap') end
}
use {
'nvim-telescope/telescope-dap.nvim',
after = 'nvim-dap'
}
use {
'rcarriga/nvim-dap-ui',
after = 'nvim-dap',
config = function() require('plugins.dapui') end
}
-- toggleterm
use {
'akinsho/toggleterm.nvim',
cmd = 'ToggleTerm*',
config = function() require('plugins.toggleterm') end
}
-- neoformat
use {
'sbdchd/neoformat',
cmd = 'Neoformat',
config = function() require('plugins.neoformat') end
}
-- comment.nvim
use {
'numToStr/Comment.nvim',
event = 'BufRead',
config = function() require('plugins.comment') end
}
-- fugitive
use {
'tpope/vim-fugitive',
cmd = 'G*'
}
--
-- files (and more)
--
-- telescope
use {
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
requires = {'nvim-lua/plenary.nvim'},
config = function() require('plugins.telescope') end
}
-- nvim tree
use {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = function() require('plugins.nvim-tree') end
}
--
-- looks
--
-- lualine
use {
'hoob3rt/lualine.nvim',
config = function() require('plugins.lualine') end
}
--
-- colorscheme
--
use {
-- 'crusoexia/vim-monokai',
'dylanaraps/wal.vim',
config = function() require('plugins.colors') end,
after = 'nvim-treesitter'
}
--
-- qol
--
-- blankline
use {
'lukas-reineke/indent-blankline.nvim',
event = 'VimEnter'
}
-- highlight yank
use {
'machakann/vim-highlightedyank',
event = 'TextYankPost'
}
-- tabular
use {
'godlygeek/tabular',
cmd = 'Tabularize'
}
-- maximizer
use {
'szw/vim-maximizer',
cmd = 'MaximizerToggle'
}
-- whichkey
use {
'folke/which-key.nvim',
config = function() require('plugins.whichkey') end
}
--
-- filetype specific
--
-- csv
use {
'chrisbra/csv.vim',
ft = 'csv'
}
-- latex
use {
'lervag/vimtex',
ft = 'tex',
config = function() require('plugins.vimtex') end
}
--
-- misc
--
use {
'vimwiki/vimwiki',
config = function() require('plugins.vimwiki') end
}
end)

View File

@ -0,0 +1,6 @@
-- autopairs
require('nvim-autopairs').setup{}
-- insert () after selecting functions
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))

View File

@ -0,0 +1,27 @@
vim.opt.completeopt = { 'menuone', 'noselect' }
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true
})
},
sources = {
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'vsnip' }
}
})

View File

@ -0,0 +1,4 @@
-- colorscheme
vim.cmd 'colorscheme wal'
-- vim.cmd 'colorscheme monokai'
vim.cmd 'highlight Pmenu ctermbg=black'

View File

@ -0,0 +1 @@
require("Comment").setup()

View File

@ -0,0 +1,121 @@
local dap = require('dap')
--
-- go
--
-- dap.adapters.go = function(callback, config)
-- local stdout = vim.loop.new_pipe(false)
-- local handle local pid_or_err local port = 38697
-- local opts = {
-- stdio = {nil, stdout},
-- args = {"dap", "-l", "127.0.0.1:" .. port},
-- detached = true
-- }
-- handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code)
-- stdout:close()
-- handle:close()
-- if code ~= 0 then
-- print('dlv exited with code', code)
-- end
-- end)
-- assert(handle, 'Error running dlv: ' .. tostring(pid_or_err))
-- stdout:read_start(function(err, chunk)
-- assert(not err, err)
-- if chunk then
-- vim.schedule(function()
-- require('dap.repl').append(chunk)
-- end)
-- end
-- end)
-- vim.defer_fn(
-- function()
-- callback({type = "server", host = "127.0.0.1", port = port})
-- end,
-- 100)
-- end
dap.adapters.go = {
type = "server",
host = "127.0.0.1",
port = 38697,
}
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
dap.configurations.go = {
{
type = "go",
name = "Debug",
request = "launch",
program = "${fileDirname}"
},
{
type = "go",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "${file}"
},
-- works with go.mod packages and sub packages
{
type = "go",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}"
}
}
--
-- python
--
dap.adapters.python = {
type = 'executable';
command = 'python';
args = { '-m', 'debugpy.adapter' };
}
dap.configurations.python = {
{
type = 'python';
request = 'launch';
name = "Launch file";
program = "${file}";
pythonPath = function()
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
return cwd .. '/.venv/bin/python'
else
return '/usr/bin/python'
end
end;
},
}
--
-- C
--
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode',
name = "lldb"
}
dap.configurations.c = {
{
name = "Launch",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
runInTerminal = false,
},
}

View File

@ -0,0 +1 @@
require("dapui").setup()

View File

@ -0,0 +1,5 @@
require('lint').linters_by_ft = {
python = {'mypy'}
}
vim.cmd("au BufWrite <buffer> lua require('lint').try_lint()")

View File

@ -0,0 +1,17 @@
local lsp = require('lspconfig')
-- language servers
lsp.pyright.setup{
settings = {
python = {
analysis = {
typeCheckingMode = "off"
}
}
}
}
lsp.gopls.setup{}
lsp.clangd.setup{}
lsp.texlab.setup{}
lsp.rust_analyzer.setup{}
lsp.jdtls.setup{ cmd = { "jdtls" } }

View File

@ -0,0 +1,8 @@
-- lualine colorscheme
require('lualine').setup{
options = {
theme = 'auto',
section_separators = {'', ''},
component_separators = {'', ''}
}
}

View File

@ -0,0 +1 @@
vim.g.neoformat_enabled_python = {'yapf'}

View File

@ -0,0 +1,8 @@
-- nvim tree
require'nvim-tree'.setup{
auto_close = true,
update_cwd = true,
diagnostics = {
enable = true,
},
}

View File

@ -0,0 +1,8 @@
-- telescope settings
require('telescope').setup{
defaults = {
-- sorting
file_sorter = require'telescope.sorters'.get_fzy_sorter,
generic_sorter = require'telescope.sorters'.get_fzy_sorter,
}
}

View File

@ -0,0 +1,2 @@
vim.o.hidden = true
require("toggleterm").setup{}

View File

@ -0,0 +1,5 @@
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}

View File

@ -0,0 +1,5 @@
-- ignore certain errors
vim.g.vimtex_quickfix_ignore_filters = { 'Underfull', 'Overfull', 'babel' }
-- use zathura as the pdf viewer
vim.g.vimtex_view_general_viewer = 'zathura'

View File

@ -0,0 +1,2 @@
vim.cmd("let g:vimwiki_list = [{'path': '~/misc/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]")
vim.cmd("let g:vimwiki_key_mappings = { 'global': 0, }")

View File

@ -0,0 +1,76 @@
local wk = require("which-key")
wk.register({
a = {
name = "Actions",
r = "Reload Config"
},
d = {
name = "Debug",
b = "Toggle Breakpoint",
c = "Continue",
h = "Telescope",
i = "Step Into",
l = "Run Last",
n = "Step Over",
o = "Step Out",
p = "List Breakpoints",
q = "Stop",
u = "Toggle UI",
v = "Show Variables"
},
g = {
name = "Language",
D = "Go To Declaration",
a = "Code Actions",
d = "Go To Definition",
e = "Show Line Diagnostics",
f = "Format Code",
i = "Show Implementations",
k = "Hover",
n = "Rename",
q = "Show Diagnostics",
r = "Show References",
t = "Show Type Definition"
},
m = {
name = "Keymap",
e = "English",
e = "Hebrew"
},
s = {
name = "Splits & Buffers",
v = "Vertical Split",
z = "Horizontal Split Split",
t = "New Tab",
b = "Show Buffers",
h = "Left Tab",
l = "Right Tab",
},
t = {
name = "Telescope",
l = "Lsp Workspace Symbols",
o = "Old Files",
g = "Grep",
s = "Treesitter",
m = "Git Status",
b = "Git Branches",
c = "Git Commits",
f = "Git Files"
},
C = "Terminal",
F = "Fuzzy Files",
Q = "Quit All",
S = "Save All",
X = "Quit All Without Saving",
c = "Toggle All Terminal",
f = "File Manager",
f = "File Manager",
h = "Left Split",
j = "Down Split",
k = "Up Split",
l = "Right Split",
q = "Quit",
s = "Save",
x = "Quit Without Saving"
}, { prefix = "<leader>" })
wk.setup{}