diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 0000000..9221559 --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,6 @@ +local config = { + cmd = {'/path/to/jdt-language-server/bin/jdtls'}, + root_dir = vim.fs.dirname(vim.fs.find({'.gradlew', '.git', 'mvnw'}, { upward = true })[1]), +} +require('jdtls').start_or_attach(config) + diff --git a/init.lua b/init.lua index 2a1c90b..c01a90d 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,9 @@ for _, name in ipairs({ 'reload', 'settings', + 'mappings', 'plugins', 'neovide', - 'theme' + 'theme', + 'preview' }) do require('config.' .. name) end diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua new file mode 100644 index 0000000..e8d1264 --- /dev/null +++ b/lua/config/mappings.lua @@ -0,0 +1,50 @@ +local u = require 'config.utils' + +-- terminal +local m = u.mapping +m.map('t', '', '') +m.map('t', '', 'h') +m.map('t', '', 'j') +m.map('t', '', 'k') +m.map('t', '', 'l') +m.nmap('tm', 'belowright 7sptermsetlocal nonuA') + +-- off search highlight when escape is pressed +m.nmap('', 'noh') + +-- spell checking +m.cmd('spl', 'setlocal spell spelllang=en_us') +m.cmd('spL', 'setlocal nospell') + +-- colemak-dh +local l = u.layout +l.swap('n', 'h') +l.swap('e', 'j') +l.swap('i', 'k') +l.swap('o', 'l') +l.map('e','gj') +l.map('i','gk') + +l.swap('n', 'h') +l.swap('e', 'j') +l.swap('i', 'k') +l.swap('o', 'l') +l.swap('N', 'H') +l.swap('E', 'J') +l.swap('I', 'K') +l.swap('O', 'L') + +l.swap('N', 'H') +l.swap('O', 'L') + +l.map('', 'h') +l.map('', 'j') +l.map('', 'k') +l.map('', 'l') + +l.map('', 'vert res -1') +l.map('', 'vert res +1') + +-- ascension +m.map('x','p', '\"_dp') + diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua index 1bf5fb7..06d1427 100644 --- a/lua/config/plugins.lua +++ b/lua/config/plugins.lua @@ -14,10 +14,10 @@ packer.startup(function(use) -- plugin categories require 'config.plugins.telescope'(use) require 'config.plugins.tree'(use) - require 'config.plugins.syntax'(use) require 'config.plugins.cmp'(use) require 'config.plugins.lsp'(use) require 'config.plugins.visual'(use) + require 'config.plugins.util'(use) -- sync if bootstrapped if PACKER_BOOTSTRAP then diff --git a/lua/config/plugins/cmp.lua b/lua/config/plugins/cmp.lua index 37b2b06..c270ad6 100644 --- a/lua/config/plugins/cmp.lua +++ b/lua/config/plugins/cmp.lua @@ -25,6 +25,7 @@ return function(use) { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, + { name = 'neorg' }, }), }) end diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua index 38fbcbf..92246d4 100644 --- a/lua/config/plugins/lsp.lua +++ b/lua/config/plugins/lsp.lua @@ -32,10 +32,12 @@ local config = function() map('D', vim.lsp.buf.type_definition) map('rn', vim.lsp.buf.rename) map('ca', vim.lsp.buf.code_action) - map('fm', vim.lsp.buf.formatting) + map('fm', function() + vim.lsp.buf.format { async = true } + end) end - local capabilities = require 'cmp_nvim_lsp'.update_capabilities( + local capabilities = require 'cmp_nvim_lsp'.default_capabilities( vim.lsp.protocol.make_client_capabilities() ) @@ -48,7 +50,8 @@ local config = function() globals = { 'vim' }, }, workspace = { - library = vim.api.nvim_get_runtime_file("", true) + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false }, telemetry = { enable = false, @@ -71,6 +74,18 @@ local config = function() on_attach = on_attach, capabilities = capabilities, } + require 'lspconfig'.clangd.setup { + on_attach = on_attach, + capabilities = capabilities, + } + require 'lspconfig'.asm_lsp.setup { + on_attach = on_attach, + capabilities = capabilities, + } + require 'lspconfig'.pylsp.setup { + on_attach = on_attach, + capabilities = capabilities, + } end return function(use) @@ -89,4 +104,8 @@ return function(use) 'windwp/nvim-autopairs', config = function() require 'nvim-autopairs'.setup {} end } + use { + 'scalameta/nvim-metals', + requires = { "nvim-lua/plenary.nvim" } + } end diff --git a/lua/config/plugins/syntax.lua b/lua/config/plugins/syntax.lua deleted file mode 100644 index d73f981..0000000 --- a/lua/config/plugins/syntax.lua +++ /dev/null @@ -1,15 +0,0 @@ -return function(use) - use { - 'nvim-treesitter/nvim-treesitter', - run = function() - require 'nvim-treesitter.install'.update { - with_sync = true - } - end, - config = function() - require 'nvim-treesitter.configs'.setup { - highlight = { enable = true } - } - end, - } -end diff --git a/lua/config/plugins/telescope.lua b/lua/config/plugins/telescope.lua index 96a7af0..562c58c 100644 --- a/lua/config/plugins/telescope.lua +++ b/lua/config/plugins/telescope.lua @@ -33,7 +33,7 @@ return function(use) require('icon-picker').setup {} local u = require 'config.utils'.mapping u.cmd('fi', 'IconPickerYank alt_font symbols nerd_font emoji') - vim.keymap.set('i', '', 'IconPickerInsert alt_font symbols nerd_font emoji') + vim.keymap.set('i', '', 'IconPickerInsert alt_font symbols nerd_font emoji') end, }) end diff --git a/lua/config/plugins/tree.lua b/lua/config/plugins/tree.lua index af8d8d7..9b56c35 100644 --- a/lua/config/plugins/tree.lua +++ b/lua/config/plugins/tree.lua @@ -10,13 +10,18 @@ return function(use) config = function() vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]] require 'neo-tree'.setup { + close_if_last_window = true, filesystem = { filtered_items = { visible = true, - } + }, }, window = { - width = 30, + width = 25, + mappings = { + ["e"] = "none", + ["j"] = "toggle_auto_expand_width", + } }, } diff --git a/lua/config/plugins/util.lua b/lua/config/plugins/util.lua new file mode 100644 index 0000000..8270c70 --- /dev/null +++ b/lua/config/plugins/util.lua @@ -0,0 +1,31 @@ +return function(use) + use { + 'nvim-neorg/neorg', + tag = '0.0.12', + config = function() + require('neorg').setup { + load = { + ['core.defaults'] = {}, + ['core.norg.concealer'] = {}, + ['core.norg.completion'] = { + config = { + engine = 'nvim-cmp' + } + }, + ['core.export'] = {}, + } + } + end, + requires = 'nvim-lua/plenary.nvim' + } + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + }) + vim.cmd([[ + function! OpenMarkdownPreview (url) + execute "silent ! firefox --new-window " . a:url + endfunction + let g:mkdp_browserfunc = 'OpenMarkdownPreview' + ]]) +end diff --git a/lua/config/plugins/visual.lua b/lua/config/plugins/visual.lua index a354d5d..909c8c4 100644 --- a/lua/config/plugins/visual.lua +++ b/lua/config/plugins/visual.lua @@ -39,4 +39,24 @@ return function(use) 'lewis6991/gitsigns.nvim', config = function() require 'gitsigns'.setup() end } + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + require 'nvim-treesitter.install'.update { + with_sync = true + } + end, + config = function() + require 'nvim-treesitter.configs'.setup { + ensure_installed = {"norg"}, + highlight = { enable = true } + } + end, + } + use { + 'elkowar/yuck.vim' + } + use { + 'kmonad/kmonad-vim' + } end diff --git a/lua/config/preview.lua b/lua/config/preview.lua new file mode 100644 index 0000000..3ab17db --- /dev/null +++ b/lua/config/preview.lua @@ -0,0 +1,17 @@ +local u = require 'config.utils' + +local g = vim.api.nvim_create_augroup('preview', {}) + +vim.api.nvim_create_autocmd('BufWritePost', { + group = g, + pattern = '*.tex', + callback = function(arg) + local dir = arg.file:match('.*/') + local args = '' + if dir ~= nil then + args = '-output-directory=\''..dir..'\' ' + end + vim.cmd('silent exec "!pdflatex '..args..'\''..arg.file..'\'"') + end +}) + diff --git a/lua/config/reload.lua b/lua/config/reload.lua index d9d05d9..916f916 100644 --- a/lua/config/reload.lua +++ b/lua/config/reload.lua @@ -5,12 +5,14 @@ local g = vim.api.nvim_create_augroup('reload', {}) -- reload these files when written to for _, mod in ipairs({ - 'config.reload', - 'config.settings', - 'config.utils', - 'config.neovide', - 'config.theme', -}) do u.mod_post_write(g, mod, u.reload) end + 'reload', + 'settings', + 'mappings', + 'utils', + 'neovide', + 'theme', + 'preview', +}) do u.mod_post_write(g, 'config.' .. mod, u.reload) end -- reload plugin files when written to diff --git a/lua/config/settings.lua b/lua/config/settings.lua index cbc7b9b..0020c7f 100644 --- a/lua/config/settings.lua +++ b/lua/config/settings.lua @@ -1,12 +1,15 @@ -local u = require 'config.utils' local o = vim.o +local g = vim.g -- basic stuff o.number = true +o.relativenumber = true +o.showmode = false +o.clipboard = 'unnamedplus' + +g.mapleader = ' ' vim.cmd('filetype plugin on') vim.cmd('syntax on') -o.cmdheight = 2 -vim.g.mapleader = ' ' -- line break (wrapping) settings o.linebreak = true @@ -39,46 +42,3 @@ vim.diagnostic.config({ virtual_text = { prefix = '●' }; }) --- terminal -local m = u.mapping -m.map('t', '', '') -m.map('t', '', 'h') -m.map('t', '', 'j') -m.map('t', '', 'k') -m.map('t', '', 'l') -m.nmap('tm', 'belowright 7sptermsetlocal nonuA') - --- off search highlight when escape is pressed -m.nmap('', 'noh') - --- yank to clipboard -m.map('v', 'y', '"+y') - --- spell checking -m.cmd('sp', 'setlocal spell spelllang=en_us') -m.cmd('nsp', 'setlocal nospell') - --- colemak-dh -local l = u.layout -l.swap('n', 'h') -l.swap('e', 'j') -l.swap('i', 'k') -l.swap('o', 'l') - -l.swap('n', 'h') -l.swap('e', 'j') -l.swap('i', 'k') -l.swap('o', 'l') -l.swap('N', 'H') -l.swap('E', 'J') -l.swap('I', 'K') -l.swap('O', 'L') - -l.swap('N', 'H') -l.swap('O', 'L') - -l.swap('', 'h') -l.swap('', 'j') -l.swap('', 'k') -l.swap('', 'l') - diff --git a/lua/config/theme.lua b/lua/config/theme.lua index 1dca3b9..55a96fe 100644 --- a/lua/config/theme.lua +++ b/lua/config/theme.lua @@ -13,4 +13,7 @@ vim.cmd [[match ExtraWhitespace /\s\+$/]] gbhl('Normal', 'none') gbhl('EndOfBuffer', 'none') gbhl('SignColumn', 'none') +gbhl('NeoTreeNormal', 'none') +gbhl('NeoTreeNormalNC', 'none') +gbhl('NeoTreeEndOfBuffer', 'none')