diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..6e91cef --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,14 @@ +require('plugins') +require('globals_opts') +require('native_commands') +require('nvim-lightbulb_config') +require('nvimtree') +require('treesitter_config') +require('dap_config') +require('mason_config') +require('new_lsp_conf') +require('cmp_config') +require('toggleterm_config') +require('virtual_lines_config') +require('keymap') +require("null-ls_config") diff --git a/nvim/init.vim b/nvim/init.vim_bkp similarity index 72% rename from nvim/init.vim rename to nvim/init.vim_bkp index 27f7ff9..adea0a8 100644 --- a/nvim/init.vim +++ b/nvim/init.vim_bkp @@ -10,6 +10,8 @@ set textwidth=120 set cursorline hi CursorLine term=bold cterm=bold ctermbg=darkgrey set tabstop=2 +set softtabstop=2 +set expandtab set shiftwidth=2 set matchpairs+=<:> set showmode @@ -59,7 +61,11 @@ set termguicolors Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'waycrate/swhkd-vim' Plug 'kmonad/kmonad-vim' - Plug 'tpope/vim-surround' + Plug 'nvim-lua/plenary.nvim' + Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.*'} + Plug 'https://git.sr.ht/~whynothugo/lsp_lines.nvim' + Plug 'MunifTanjim/nui.nvim' + Plug 'arnarg/todotxt.nvim' call plug#end() autocmd vimenter * colorscheme gruvbox @@ -67,14 +73,20 @@ set termguicolors let g:clang_format#auto_format=0 set completeopt=menuone,noselect + +highlight NvimTreeFolderIcon guibg=blue + +lua require('cmp_config') lua require('nvimtree') lua require('lsp_conf') lua require('treesitter_config') lua require('dap_config') lua require('jester') lua require('mason_config') -lua require'fzf_lsp'.setup() +lua require('toggleterm_config') +lua require('virtual_lines_config') +lua require('todotxt_config') "Leader nnoremap @@ -93,6 +105,7 @@ let mapleader=" " nnoremap :noh map f :FZF map F :Rg + nnoremap ca lua vim.lsp.buf.code_action() nnoremap gd lua vim.lsp.buf.definition() nnoremap gD lua vim.lsp.buf.declaration() @@ -100,8 +113,13 @@ let mapleader=" " nnoremap rn lua vim.lsp.buf.rename() nnoremap K lua vim.lsp.buf.hover() + nnoremap b :Buffers + + nnoremap :bnext + nnoremap :bprevious + nnoremap J lua vim.diagnostic.open_float() - nnoremap lua vim.lsp.buf.formatting() + nnoremap lua vim.lsp.buf.format({async = true}) inoremap lua vim.lsp.buf.signature_help() nnoremap lua require'dap'.toggle_breakpoint() @@ -109,11 +127,15 @@ let mapleader=" " nnoremap lua require'dap'.step_over() nnoremap lua require'dap'.step_into() + tnoremap + + nnoremap td :ToDoTxtTasksToggle + autocmd BufWritePre *.ts lua vim.lsp.buf.formatting_sync(nil, 1000) - command JestRun :lua require'jester'.run({cmd = "yarn run test -t '$result' -- $file"}) - command JestRunFile :lua require'jester'.run_file({cmd = "yarn run test -t '$result' -- $file"}) - command JestRunLast :lua require'jester'.run_last({cmd = "yarn run test -t '$result' -- $file"}) - command JestDebug :lua require'jester'.debug({cmd = "yarn run test -t '$result' -- $file"}) - command JestDebugFile :lua require'jester'.debug_file({cmd = "yarn run test -t '$result' -- $file"}) - command JestDebugLast :lua require'jester'.debug_last({cmd = "yarn run test -t '$result' -- $file"}) + command JestRun :lua require'jester'.run({cmd = "npm run test -t '$result' -- $file"}) + command JestRunFile :lua require'jester'.run_file({cmd = "npm run test -t '$result' -- $file"}) + command JestRunLast :lua require'jester'.run_last({cmd = "npm run test -t '$result' -- $file"}) + command JestDebug :lua require'jester'.debug({cmd = "npm run test -t '$result' -- $file"}) + command JestDebugFile :lua require'jester'.debug_file({cmd = "npm run test -t '$result' -- $file"}) + command JestDebugLast :lua require'jester'.debug_last({cmd = "npm run test -t '$result' -- $file"}) diff --git a/nvim/lua/dap_config.lua b/nvim/lua/dap_config.lua index e69de29..f120486 100644 --- a/nvim/lua/dap_config.lua +++ b/nvim/lua/dap_config.lua @@ -0,0 +1,8 @@ +local dap = require('dap') +dap.adapters.node2 = { + type = 'executable', + command = 'node', + args = {os.getenv('HOME') .. '/dev/microsoft/vscode-node-debug2/out/src/nodeDebug.js'}, +} +vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''}) +vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''}) diff --git a/nvim/lua/debugHelper.lua b/nvim/lua/debugHelper.lua new file mode 100644 index 0000000..72154d2 --- /dev/null +++ b/nvim/lua/debugHelper.lua @@ -0,0 +1,51 @@ + +local dap = require('dap') + +local function debugJest(testName, filename) + print("starting " .. testName .. " in " .. filename) + dap.run({ + type = 'node2', + request = 'launch', + cwd = vim.fn.getcwd(), + runtimeArgs = {'--inspect-brk', '/usr/local/bin/jest', '--no-coverage', '-t', testName, '--', filename}, + sourceMaps = true, + protocol = 'inspector', + skipFiles = {'/**/*.js'}, + console = 'integratedTerminal', + port = 9229, + }) +end + +local function attach() + print("attaching") + dap.run({ + type = 'node2', + request = 'attach', + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = 'inspector', + skipFiles = {'/**/*.js'}, + }) +end + +local function attachToRemote() + print("attaching") + dap.run({ + type = 'node2', + request = 'attach', + address = "127.0.0.1", + port = 9229, + localRoot = vim.fn.getcwd(), + remoteRoot = "/home/vcap/app", + sourceMaps = true, + protocol = 'inspector', + skipFiles = {'/**/*.js'}, + }) +end + +return { + debugJest = debugJest, + attach = attach, + attachToRemote = attachToRemote, +} + diff --git a/nvim/lua/globals_opts.lua b/nvim/lua/globals_opts.lua new file mode 100644 index 0000000..5627cbf --- /dev/null +++ b/nvim/lua/globals_opts.lua @@ -0,0 +1,25 @@ + +local set = vim.opt +set.modelines=0 +set.hidden=true +set.number=true +set.ruler=true +set.visualbell=true +set.textwidth=120 +set.cursorline=true +set.tabstop=2 +set.shiftwidth=2 +set.showmode=true +set.showcmd=true +set.showmatch=true +set.hlsearch=true +set.ignorecase=true +set.smartcase=true +set.incsearch=true +set.wrapscan=true +set.scrolloff=999 +set.backspace="indent,eol,start" +set.mouse="nicr" +set.termguicolors=true +set.matchpairs:append("<:>") +set.completeopt="menuone,noselect,preview" diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua new file mode 100644 index 0000000..a05d68c --- /dev/null +++ b/nvim/lua/keymap.lua @@ -0,0 +1,31 @@ + +function map(mode, shortcut, command) + vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) +end + +function nmap(shortcut, command) + map('n', shortcut, command) +end + +function imap(shortcut, command) + map('i', shortcut, command) +end + +function xmap(shortcut, command) + map('x', shortcut, command) +end + +nmap("","") + +vim.g.mapleader = " " + +xmap("p",'\"_dP') +nmap("fg", "lua require('telescope.builtin').live_grep()") +nmap("fb", "lua require('telescope.builtin').buffers()") +nmap("fh", "lua require('telescope.builtin').help_tags()") +nmap("ff", "lua require('telescope.builtin').find_files()") + +nmap("b","lua require('telescope.builtin').buffers()") +nmap("",":NvimTreeToggle") +nmap("r",":NvimTreeRefresh") +nmap("n",":NvimTreeToggle") diff --git a/nvim/lua/lsp_conf.lua b/nvim/lua/lsp_conf.lua index 089f0fd..294c9f8 100644 --- a/nvim/lua/lsp_conf.lua +++ b/nvim/lua/lsp_conf.lua @@ -1,16 +1,19 @@ - -local cmp = require("cmp") -local luasnip = require("luasnip") - local capabilites = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + require'lspconfig'.tsserver.setup{ capabilites = capabilites } +require'lspconfig'.jsonls.setup{ +capabilites = capabilites +} require'lspconfig'.dockerls.setup{ capabilites = capabilites } require'lspconfig'.eslint.setup{ -capabilites = capabilites +capabilites = capabilites, +settings= { + run = "onSave" +} } require'lspconfig'.gdscript.setup{ capabilites = capabilites @@ -28,67 +31,5 @@ require'lspconfig'.bashls.setup{ capabilites = capabilites } -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line -1, line, true)[1]:sub(col,col):match("%s") == nil -end -cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = 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.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end,{"i","s"}), - [''] = 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"}) - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, -- For luasnip users. - }, { - { name = 'buffer' }, - }) - }) - -cmp.setup.cmdline('/',{ -sources = { - { name = 'buffer' } - } -}) - -cmp.setup.cmdline(':',{ -sources = cmp.config.sources({ -{name = 'path'} -},{{name='cmdline'}}) -}) - +require'fzf_lsp'.setup() diff --git a/nvim/lua/native_commands.lua b/nvim/lua/native_commands.lua new file mode 100644 index 0000000..f705c5d --- /dev/null +++ b/nvim/lua/native_commands.lua @@ -0,0 +1,6 @@ + +vim.cmd('hi CursorLine term=bold cterm=bold ctermbg=darkgrey') +vim.cmd[[colorscheme tokyonight]] +vim.cmd([[ + runtime macros/sandwich/keymap/surround.vim +]]) diff --git a/nvim/lua/null-ls_config.lua b/nvim/lua/null-ls_config.lua new file mode 100644 index 0000000..28fe85d --- /dev/null +++ b/nvim/lua/null-ls_config.lua @@ -0,0 +1,8 @@ + +require("null-ls").setup({ + sources = { + require("null-ls").builtins.formatting.stylua, + require("null-ls").builtins.diagnostics.eslint, + require("null-ls").builtins.completion.spell, + }, +}) diff --git a/nvim/lua/nvimtree.lua b/nvim/lua/nvimtree.lua index 102459e..f00e0a4 100644 --- a/nvim/lua/nvimtree.lua +++ b/nvim/lua/nvimtree.lua @@ -10,7 +10,7 @@ require'nvim-tree'.setup { folder_arrow= false }, glyphs = { - default= "", + default= "", symlink= "", git= { unstaged= "✗", @@ -45,8 +45,8 @@ require'nvim-tree'.setup { indent_markers = { enable = true, icons = { - corner = "└ ", - edge = "│ ", + corner = "└", + edge = "│ ", none = " ", } } @@ -57,10 +57,11 @@ require'nvim-tree'.setup { open_on_setup = false, ignore_ft_on_setup = {}, open_on_tab = false, - hijack_cursor = false, + hijack_cursor = true, + auto_reload_on_write = true, update_cwd = false, diagnostics = { - enable = false, + enable = true, icons = { hint = "", info = "", @@ -88,6 +89,7 @@ require'nvim-tree'.setup { }, actions = { open_file = { + resize_window = false, window_picker = { exclude = { filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, @@ -97,8 +99,7 @@ require'nvim-tree'.setup { } }, view = { - width = 25, - height = 30, + width = 35, hide_root_folder = false, side = 'left', mappings = { diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..8fb21e8 --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,48 @@ +require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + "WhoIsSethDaniel/mason-tool-installer.nvim" + } + use 'mfussenegger/nvim-dap' + use 'jose-elias-alvarez/null-ls.nvim' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.0', + requires = { {'nvim-lua/plenary.nvim'} } + } + use 'nvim-lua/lsp-status.nvim' + use 'jiangmiao/auto-pairs' + use 'machakann/vim-sandwich' + use 'machakann/vim-highlightedyank' + use 'bling/vim-airline' + use 'airblade/vim-gitgutter' + use 'easymotion/vim-easymotion' + use { + 'antoinemadec/FixCursorHold.nvim', + 'kosayoda/nvim-lightbulb' + } + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-cmdline' + use 'saadparwaiz1/cmp_luasnip' + use 'L3MON4D3/LuaSnip' + use 'kyazdani42/nvim-web-devicons' + use 'kyazdani42/nvim-tree.lua' + use 'tpope/vim-fugitive' + use { + 'nvim-treesitter/nvim-treesitter', + run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, + } + use 'folke/tokyonight.nvim' + use 'simrat39/rust-tools.nvim' + use {"akinsho/toggleterm.nvim", tag = 'v2.*', config = function() + require("toggleterm").setup() + end} + use 'https://git.sr.ht/~whynothugo/lsp_lines.nvim' + --use 'morhetz/gruvbox' + + end) diff --git a/nvim/lua/todotxt_config.lua b/nvim/lua/todotxt_config.lua new file mode 100644 index 0000000..3eb363d --- /dev/null +++ b/nvim/lua/todotxt_config.lua @@ -0,0 +1,9 @@ +todo = require('todotxt-nvim') +todo.setup({ + todo_file = '~/todotxt/todo.txt', + sidebar = { + width = 40, + position = 'right' + } + } +) diff --git a/nvim/lua/toggleterm_config.lua b/nvim/lua/toggleterm_config.lua new file mode 100644 index 0000000..c61ade2 --- /dev/null +++ b/nvim/lua/toggleterm_config.lua @@ -0,0 +1,11 @@ +require"toggleterm".setup{ + open_mapping = [[]], + hide_numbers = true, + direction = 'float', + float_opts = { + border = 'curved' + }, + winbar = { + enabled = false + } +} diff --git a/nvim/lua/treesitter_config.lua b/nvim/lua/treesitter_config.lua index d9a3364..7889c05 100644 --- a/nvim/lua/treesitter_config.lua +++ b/nvim/lua/treesitter_config.lua @@ -23,3 +23,16 @@ require'nvim-treesitter.configs'.setup { additional_vim_regex_highlighting = false, }, } +--- Treesitter +---BEGINWORKAROUND +--vim.api.nvim_create_autocmd({'BufEnter','BufAdd','BufNew','BufNewFile','BufWinEnter'}, { +-- group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), +-- callback = function() +-- vim.opt.foldmethod = 'expr' +-- vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' +-- end +--}) +---ENDWORKAROUND +--- Treesitter +--- Utility functions +--- diff --git a/nvim/lua/virtual_lines_config.lua b/nvim/lua/virtual_lines_config.lua new file mode 100644 index 0000000..acfe531 --- /dev/null +++ b/nvim/lua/virtual_lines_config.lua @@ -0,0 +1,9 @@ +lines = require('lsp_lines') +lines.setup() +vim.diagnostic.config({ virtual_text = false }); +vim.keymap.set( + "", + "tl", + lines.toggle, + { desc = "Toggle lsp_lines" } +); diff --git a/nvim/start.lua b/nvim/start.lua deleted file mode 100644 index ce178b1..0000000 --- a/nvim/start.lua +++ /dev/null @@ -1,133 +0,0 @@ -local set = vim.opt -set.modelines=0 -set.hidden=true -set.number=true -set.ruler=true -set.visualbell=true -set.textwidth=120 -set.cursorline=true -set.tabstop=2 -set.shiftwidth=2 -set.showmode=true -set.showcmd=true -set.showmatch=true -set.hlsearch=true -set.ignorecase=true -set.smartcase=true -set.incsearch=true -set.wrapscan=true -set.scrolloff=999 -set.backspace="indent,eol,start" -set.mouse="nicr" -set.termguicolors=true -set.matchpairs:append("<:>") -set.completeopt="menuone,noselect,preview" - -vim.cmd("hi CursorLine term=bold cterm=bold ctermbg=darkgrey") - -require('packer').startup(function(use) - use 'wbthomason/packer.nvim' - use { - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", - "WhoIsSethDaniel/mason-tool-installer.nvim" - } - use 'mfussenegger/nvim-dap' - use 'jose-elias-alvarez/null-ls.nvim' - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.0', - requires = { {'nvim-lua/plenary.nvim'} } - } - use 'nvim-lua/lsp-status.nvim' - use 'jiangmiao/auto-pairs' - use 'machakann/vim-sandwich' - use 'machakann/vim-highlightedyank' - use 'bling/vim-airline' - use 'airblade/vim-gitgutter' - use 'easymotion/vim-easymotion' - use { - 'antoinemadec/FixCursorHold.nvim', - 'kosayoda/nvim-lightbulb' - } - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-cmdline' - use 'saadparwaiz1/cmp_luasnip' - use 'L3MON4D3/LuaSnip' - use 'kyazdani42/nvim-web-devicons' - use 'kyazdani42/nvim-tree.lua' - use 'tpope/vim-fugitive' - use { - 'nvim-treesitter/nvim-treesitter', - run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, - } - use 'folke/tokyonight.nvim' - use 'simrat39/rust-tools.nvim' - --use 'morhetz/gruvbox' - - end) - -vim.cmd[[colorscheme tokyonight]] - ---- Treesitter ----BEGINWORKAROUND ---vim.api.nvim_create_autocmd({'BufEnter','BufAdd','BufNew','BufNewFile','BufWinEnter'}, { --- group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), --- callback = function() --- vim.opt.foldmethod = 'expr' --- vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' --- end ---}) ----ENDWORKAROUND ---- Treesitter ---- Utility functions -function map(mode, shortcut, command) - vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) -end - -function nmap(shortcut, command) - map('n', shortcut, command) -end - -function imap(shortcut, command) - map('i', shortcut, command) -end - -function xmap(shortcut, command) - map('x', shortcut, command) -end ---- -require('nvim-lightbulb_config') -require('nvimtree') -require('treesitter_config') -require('dap_config') -require('mason_config') -require('new_lsp_conf') -require('cmp_config') -require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.diagnostics.eslint, - require("null-ls").builtins.completion.spell, - }, -}) - -vim.cmd([[ - runtime macros/sandwich/keymap/surround.vim -]]) - -nmap("","") - -vim.g.mapleader = " " - -xmap("p",'\"_dP') -nmap("fg", "lua require('telescope.builtin').live_grep()") -nmap("fb", "lua require('telescope.builtin').buffers()") -nmap("fh", "lua require('telescope.builtin').help_tags()") -nmap("ff", "lua require('telescope.builtin').find_files()") - -nmap("",":NvimTreeToggle") -nmap("r",":NvimTreeRefresh") -nmap("n",":NvimTreeToggle") diff --git a/startpage/deploy.sh b/startpage/deploy.sh index 015cce7..07c11b2 100755 --- a/startpage/deploy.sh +++ b/startpage/deploy.sh @@ -1,2 +1,5 @@ #!/bin/bash -docker build -t dotfiles/local_startpage:latest . +REPO="startpage" +docker build -t $REPO:latest . +docker tag $REPO:latest registry.brudi.xyz/$REPO:latest +docker push registry.brudi.xyz/$REPO:latest