diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..734f787 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,39 @@ +[submodule "pack/packages/start/dracula_vim_colorscheme"] + path = pack/packages/start/dracula_vim_colorscheme + url = https://github.com/dracula/vim.git +[submodule "pack/packages/start/nvim-quickcomment"] + path = pack/packages/start/nvim-quickcomment + url = https://github.com/Stephen-Seo/nvim-quickcomment.git +[submodule "pack/packages/start/nvim-treesitter"] + path = pack/packages/start/nvim-treesitter + url = https://github.com/nvim-treesitter/nvim-treesitter.git +[submodule "pack/packages/start/vim-gitgutter"] + path = pack/packages/start/vim-gitgutter + url = https://github.com/airblade/vim-gitgutter.git +[submodule "pack/packages/start/vim-localvimrc"] + path = pack/packages/start/vim-localvimrc + url = https://github.com/embear/vim-localvimrc.git +[submodule "lsppack/pack/lsppackages/start/cmp-buffer"] + path = lsppack/pack/lsppackages/start/cmp-buffer + url = https://github.com/hrsh7th/cmp-buffer.git +[submodule "lsppack/pack/lsppackages/start/cmp-cmdline"] + path = lsppack/pack/lsppackages/start/cmp-cmdline + url = https://github.com/hrsh7th/cmp-cmdline.git +[submodule "lsppack/pack/lsppackages/start/cmp-nvim-lsp"] + path = lsppack/pack/lsppackages/start/cmp-nvim-lsp + url = https://github.com/hrsh7th/cmp-nvim-lsp.git +[submodule "lsppack/pack/lsppackages/start/cmp-path"] + path = lsppack/pack/lsppackages/start/cmp-path + url = https://github.com/hrsh7th/cmp-path.git +[submodule "lsppack/pack/lsppackages/start/cmp-vsnip"] + path = lsppack/pack/lsppackages/start/cmp-vsnip + url = https://github.com/hrsh7th/cmp-vsnip.git +[submodule "lsppack/pack/lsppackages/start/nvim-cmp"] + path = lsppack/pack/lsppackages/start/nvim-cmp + url = https://github.com/hrsh7th/nvim-cmp.git +[submodule "lsppack/pack/lsppackages/start/nvim-lspconfig"] + path = lsppack/pack/lsppackages/start/nvim-lspconfig + url = https://github.com/neovim/nvim-lspconfig.git +[submodule "lsppack/pack/lsppackages/start/vim-vsnip"] + path = lsppack/pack/lsppackages/start/vim-vsnip + url = https://github.com/hrsh7th/vim-vsnip.git diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..84a9a4e --- /dev/null +++ b/init.lua @@ -0,0 +1,76 @@ +-- settings +vim.o.nu = true +-- truecolor +vim.o.termguicolors = true +-- color scheme +--vim.g.colors_name = "jellybeans" +--vim.api.nvim_command("color jellybeans") +vim.api.nvim_command("let g:dracula_colorterm = 0") +vim.api.nvim_command("color dracula") +vim.o.hlsearch = true +--vim.g.syntax = "on" -- unknown how to do this in lua, but is default on +vim.o.expandtab = true +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.colorcolumn = "80" +vim.o.scrolloff = 4 +vim.o.mouse = "a" +vim.o.guifont = "JetBrainsMono 10" +vim.api.nvim_command('au BufEnter * hi ColorColumn guibg=red ctermbg=red') + +-- git commit +vim.api.nvim_command('autocmd FileType gitcommit setlocal colorcolumn=50,72') + +-- Allow tabs in Makefiles. +vim.api.nvim_command('autocmd FileType make,automake set noexpandtab shiftwidth=4 softtabstop=4') +-- Trailing whitespace and tabs are forbidden, so highlight them. +vim.api.nvim_command('highlight ForbiddenWhitespace ctermbg=yellow guibg=yellow') +vim.api.nvim_command('match ForbiddenWhitespace /\\s\\+$\\|\\t/') +-- Do not highlight spaces at the end of line while typing on that line. +vim.api.nvim_command('autocmd InsertEnter * match ForbiddenWhitespace /\\t\\|\\s\\+\\%#\\@/dev/null' + let l:output = system(l:cmd) + let l:output = substitute(l:output, '[\r\n]*$', '', '') + execute 'normal i' . l:output +endfunction +nmap i :call CJKInput() +]]) + +--vim.cmd('nmap q :echo "I accidentally hit q, I don\'t use macros"') +--vim.cmd('vmap q :echo "I accidentally hit q, I don\'t use macros"') + +vim.cmd('nmap q :lua vim.g.quickcomment_togglecommentline()') +vim.cmd('vmap q :luado vim.g.quickcomment_togglecommentline(linenr)') + +vim.g.quickcomment_whitespaceprefix = 1 + +require'nvim-treesitter.configs'.setup { + ensure_installed = { "c", "cpp", "rust", "lua" }, + sync_install = false, + ignore_install = { "javascript" }, + + highlight = { + enable = true, + disable = {}, + additional_vim_regex_highlighting = false, + }, +} + +vim.g.foldmethod_treesitter_fn = function () + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +end diff --git a/lsppack/pack/lsppackages/start/cmp-buffer b/lsppack/pack/lsppackages/start/cmp-buffer new file mode 160000 index 0000000..3022dbc --- /dev/null +++ b/lsppack/pack/lsppackages/start/cmp-buffer @@ -0,0 +1 @@ +Subproject commit 3022dbc9166796b644a841a02de8dd1cc1d311fa diff --git a/lsppack/pack/lsppackages/start/cmp-cmdline b/lsppack/pack/lsppackages/start/cmp-cmdline new file mode 160000 index 0000000..8ee981b --- /dev/null +++ b/lsppack/pack/lsppackages/start/cmp-cmdline @@ -0,0 +1 @@ +Subproject commit 8ee981b4a91f536f52add291594e89fb6645e451 diff --git a/lsppack/pack/lsppackages/start/cmp-nvim-lsp b/lsppack/pack/lsppackages/start/cmp-nvim-lsp new file mode 160000 index 0000000..44b16d1 --- /dev/null +++ b/lsppack/pack/lsppackages/start/cmp-nvim-lsp @@ -0,0 +1 @@ +Subproject commit 44b16d11215dce86f253ce0c30949813c0a90765 diff --git a/lsppack/pack/lsppackages/start/cmp-path b/lsppack/pack/lsppackages/start/cmp-path new file mode 160000 index 0000000..91ff86c --- /dev/null +++ b/lsppack/pack/lsppackages/start/cmp-path @@ -0,0 +1 @@ +Subproject commit 91ff86cd9c29299a64f968ebb45846c485725f23 diff --git a/lsppack/pack/lsppackages/start/cmp-vsnip b/lsppack/pack/lsppackages/start/cmp-vsnip new file mode 160000 index 0000000..989a8a7 --- /dev/null +++ b/lsppack/pack/lsppackages/start/cmp-vsnip @@ -0,0 +1 @@ +Subproject commit 989a8a73c44e926199bfd05fa7a516d51f2d2752 diff --git a/lsppack/pack/lsppackages/start/nvim-cmp b/lsppack/pack/lsppackages/start/nvim-cmp new file mode 160000 index 0000000..2743dd9 --- /dev/null +++ b/lsppack/pack/lsppackages/start/nvim-cmp @@ -0,0 +1 @@ +Subproject commit 2743dd989e9b932e1b4813a4927d7b84272a14e2 diff --git a/lsppack/pack/lsppackages/start/nvim-lspconfig b/lsppack/pack/lsppackages/start/nvim-lspconfig new file mode 160000 index 0000000..5dd8e2f --- /dev/null +++ b/lsppack/pack/lsppackages/start/nvim-lspconfig @@ -0,0 +1 @@ +Subproject commit 5dd8e2f105f08832ddbff1964bdde6d152aca793 diff --git a/lsppack/pack/lsppackages/start/vim-vsnip b/lsppack/pack/lsppackages/start/vim-vsnip new file mode 160000 index 0000000..7753ba9 --- /dev/null +++ b/lsppack/pack/lsppackages/start/vim-vsnip @@ -0,0 +1 @@ +Subproject commit 7753ba9c10429c29d25abfd11b4c60b76718c438 diff --git a/pack/packages/start/dracula_vim_colorscheme b/pack/packages/start/dracula_vim_colorscheme new file mode 160000 index 0000000..3e52a06 --- /dev/null +++ b/pack/packages/start/dracula_vim_colorscheme @@ -0,0 +1 @@ +Subproject commit 3e52a0682a53dd7c2c53133d45948f5a49c5fd9a diff --git a/pack/packages/start/loadlsp/autoload/loadlsp.vim b/pack/packages/start/loadlsp/autoload/loadlsp.vim new file mode 100644 index 0000000..a5fc55d --- /dev/null +++ b/pack/packages/start/loadlsp/autoload/loadlsp.vim @@ -0,0 +1,112 @@ +function! loadlsp#loadlspall() + +if exists("g:loadlspall_loaded") && g:loadlspall_loaded == 1 + echo "Already loaded" + return +else + let g:loadlspall_loaded = 1 +endif + +let l:lsppack_path = "/.config/nvim/lsppack" + +let &packpath = &packpath +\ . "," . environ()["HOME"] +\ . l:lsppack_path + +packloadall! + +" lsp + +"set completeopt=menu,menuone,noselect + +lua <'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), { 'i', 's' }), + [''] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), { 'i', 's' }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' } + }, { + { name = 'buffer' }, + }) +}) + +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) + +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +local capabilities = require('cmp_nvim_lsp').default_capabilities() +lspconfig.clangd.setup { + cmd = {"clangd", "--completion-style=detailed"}, + capabilities = capabilities +} + +local rust_features = {} + +if string.find(vim.fn.getcwd(), "git/mpd_info_screen") then + table.insert(rust_features, "unicode_support") +end + +lspconfig.rust_analyzer.setup { + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + ["cargo"] = { + ["features"] = rust_features, + }, + }, + } +} +lspconfig.gdscript.setup { + capabilities = capabilities +} +lspconfig.jedi_language_server.setup{ + capabilities = capabilities +} + +-- apply available fix +vim.api.nvim_set_keymap("n", "", "lua vim.lsp.buf.code_action()", {noremap = true}) +-- goto next warning/error +--vim.api.nvim_set_keymap("n", "", "lua vim.lsp.diagnostic.goto_next()", {noremap = true}) +vim.api.nvim_set_keymap("n", "", "lua vim.diagnostic.goto_next()", {noremap = true}) + +EOF + +" init after/ sources +let after_scripts = glob(environ()["HOME"] . l:lsppack_path . "/pack/*/start/*/after/**", 0, 1) +for item in after_scripts + if item =~ ".*\.lua$" || item =~ ".*\.vim$" + execute 'source' item + endif +endfor + +echo 'loaded lsp plugins' + +endfunction diff --git a/pack/packages/start/nvim-quickcomment b/pack/packages/start/nvim-quickcomment new file mode 160000 index 0000000..edf8141 --- /dev/null +++ b/pack/packages/start/nvim-quickcomment @@ -0,0 +1 @@ +Subproject commit edf814111b70d72ef5a25bb801036deae7e09768 diff --git a/pack/packages/start/nvim-treesitter b/pack/packages/start/nvim-treesitter new file mode 160000 index 0000000..e1ab539 --- /dev/null +++ b/pack/packages/start/nvim-treesitter @@ -0,0 +1 @@ +Subproject commit e1ab5391e5c4820dd1ffc2566d29b01573ab52a9 diff --git a/pack/packages/start/vim-gitgutter b/pack/packages/start/vim-gitgutter new file mode 160000 index 0000000..4a7ca06 --- /dev/null +++ b/pack/packages/start/vim-gitgutter @@ -0,0 +1 @@ +Subproject commit 4a7ca061af2b199a9b97041270611439e8fa2b02 diff --git a/pack/packages/start/vim-localvimrc b/pack/packages/start/vim-localvimrc new file mode 160000 index 0000000..ebb7383 --- /dev/null +++ b/pack/packages/start/vim-localvimrc @@ -0,0 +1 @@ +Subproject commit ebb73832e6795967e5a52db3636a37282871b218