diff --git a/after/ftplugin/mail.vim b/after/ftplugin/mail.vim index 1eb4bff..36fc8aa 100644 --- a/after/ftplugin/mail.vim +++ b/after/ftplugin/mail.vim @@ -1,3 +1,3 @@ iabbr mfg Mit freundlichen Grüßen - -set fdl=99 +setlocal spell +setlocal fdl=99 diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua deleted file mode 100644 index 885d28e..0000000 --- a/after/plugin/cmp.lua +++ /dev/null @@ -1,59 +0,0 @@ -local cmp = require('cmp') -local lspkind = require('lspkind') - -cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = { - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [''] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, - { name = "copilot"}, - },{ - { name = 'buffer' }, - --{ name = 'path' }, - }), - formatting = { - format = lspkind.cmp_format({ - mode = 'symbol_text', -- show only symbol annotations - maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - symbol_map = { Copilot = "" }, - }) - }, -}) - ---cmp.setup.cmdline({ '/', '?' }, { --- mapping = cmp.mapping.preset.cmdline(), --- sources = { --- { name = 'buffer' } --- } ---}) --- ----- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). ---cmp.setup.cmdline(':', { --- mapping = cmp.mapping.preset.cmdline(), --- sources = cmp.config.sources({ }, { --- { name = 'cmdline' } --- }) ---}) diff --git a/coc-settings.json b/coc-settings.json deleted file mode 100644 index 645c346..0000000 --- a/coc-settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "languageserver": { - "turtle": { - "command": "turtle_lsp", - "filetypes": ["ttl", "turtle"] - } - } -} diff --git a/ftdetect/cocor.vim b/ftdetect/cocor.vim deleted file mode 100644 index 4f00515..0000000 --- a/ftdetect/cocor.vim +++ /dev/null @@ -1,2 +0,0 @@ -au! BufRead,BufNewFile *.atg setfiletype coco -au! BufRead,BufNewFile *.wili setfiletype wili diff --git a/ftdetect/extensions.lua b/ftdetect/extensions.lua new file mode 100644 index 0000000..1098681 --- /dev/null +++ b/ftdetect/extensions.lua @@ -0,0 +1,18 @@ +vim.filetype.add({ + extension = { + }, + filename = { + ['.scalafmt.conf'] = 'hocon', + ['kitty.conf'] = 'kitty', + ['neomuttrc'] = 'neomutt', + ['template'] = 'sh', + }, + pattern = { + ['${XDG_CONFIG_HOME}/kitty/*.conf'] = 'kitty', + ['${XDG_CONFIG_HOME}/kitty/*.session'] = 'kitty-session', + }, +}) + +-- au BufRead,BufNewFile *.ttl set filetype=rdf-turtle +-- au! BufNewFile,BufRead *.xwiki set ft=xwiki syntax=xwiki +-- diff --git a/ftdetect/hocon.vim b/ftdetect/hocon.vim deleted file mode 100644 index 7e9a1e6..0000000 --- a/ftdetect/hocon.vim +++ /dev/null @@ -1 +0,0 @@ -au! BufNewFile,BufRead .scalafmt.conf set ft=hocon syntax=hocon diff --git a/ftdetect/kitty.vim b/ftdetect/kitty.vim deleted file mode 100644 index 38d8d04..0000000 --- a/ftdetect/kitty.vim +++ /dev/null @@ -1,8 +0,0 @@ -au! BufNewFile,BufRead kitty.conf set ft=kitty syntax=kitty -if exists("$XDG_CONFIG_HOME") - au! BufNewFile,BufRead $XDG_CONFIG_HOME/kitty/*.conf set ft=kitty syntax=kitty - au! BufRead,BufNewFile $XDG_CONFIG_HOME/kitty/*.session set ft=kitty-session syntax=kitty-session -else - au! BufNewFile,BufRead ~/.config/kitty/*.conf set ft=kitty syntax=kitty - au! BufRead,BufNewFile ~/.config/kitty/*.session set ft=kitty-session syntax=kitty-session -endif diff --git a/ftdetect/sc.lua b/ftdetect/sc.lua new file mode 100644 index 0000000..422a4f8 --- /dev/null +++ b/ftdetect/sc.lua @@ -0,0 +1,24 @@ +-- Override detection from lua/vim/filetype/detect.lua +-- removes match on |%w+| for SuperCollider +vim.filetype.add({ + extension = { + -- This function checks the first 25 lines of file extension "sc" to resolve + -- detection between scala and SuperCollider + sc = function(path, bufnr) + for _, line in ipairs(vim.filetype.getlines(bufnr, 1, 25)) do + if + vim.filetype.findany(line, { + 'var%s<', + 'classvar%s<', + '%^this.*', + '%+%s%w*%s{', + '%*ar%s', + }) + then + return 'supercollider' + end + end + return 'scala' + end + } +}) diff --git a/ftdetect/sieve.vim b/ftdetect/sieve.vim deleted file mode 100644 index 4c68082..0000000 --- a/ftdetect/sieve.vim +++ /dev/null @@ -1 +0,0 @@ -au! BufNewFile,BufRead *.sieve set ft=sieve syntax=sieve diff --git a/ftdetect/tolua.vim b/ftdetect/tolua.vim deleted file mode 100644 index 87cb3fd..0000000 --- a/ftdetect/tolua.vim +++ /dev/null @@ -1 +0,0 @@ -au! BufRead,BufNewFile tolua_*.pkg set ft=tolua syntax=tolua diff --git a/ftdetect/xwiki.vim b/ftdetect/xwiki.vim deleted file mode 100644 index b6a1640..0000000 --- a/ftdetect/xwiki.vim +++ /dev/null @@ -1,2 +0,0 @@ -au! BufNewFile,BufRead *.xwiki set ft=xwiki syntax=xwiki - diff --git a/ftplugin/java.lua b/ftplugin/java.lua index cf81c69..70a70bd 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -1,4 +1,3 @@ -local mylsp = require("my-lsp") local path = require("mason-core.path") local function mason_package(...) @@ -14,7 +13,6 @@ require('jdtls').start_or_attach({ on_attach = function(client, bufnr) require'jdtls.setup'.add_commands() require'jdtls'.setup_dap() - mylsp.on_attach(client, bufnr) end, init_options = { bundles = extra_bundles diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6e69387 --- /dev/null +++ b/init.lua @@ -0,0 +1,110 @@ +if vim.env['VIRTUAL_ENV'] ~= nil then + vim.g.python3_host_prog = vim.fn.system("which -a python3 | sed -n 2p | tr -d '\n'") +else + vim.g.python3_host_prog = vim.fn.system("which python3 | tr -d '\n'") +end + +-- lazy.nvim bootstrap +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup("plugins") + +vim.opt.background = "dark" +vim.g.chroma_italic_style = "bold" +vim.g.chroma_nontext_dark = 1 + +vim.opt.number = true + +vim.opt.colorcolumn = "+1" +vim.opt.textwidth = 80 +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 + +vim.opt.whichwrap = "b,s,<,>,[,],h,l" + +vim.opt.timeout = false + +vim.opt.foldmethod = "expr" +vim.opt.foldlevelstart = 99 +vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()' +vim.opt.foldenable = false + +-- todo visualbell needed? + +vim.opt.shell = "/bin/zsh" +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.inccommand = "split" + +vim.opt.wildmode = { "list:longest", "list:full" } +vim.opt.wildignore = { "*.so", "*.swp", "*.zip", "*.o" } +vim.opt.suffixes = { + ".bak", "~", ".h", ".info", ".swp", ".obj", ".info", ".aux", ".dvi", ".bbl", ".out", ".o", ".lo", + "\\.class", ".pdf" } + +vim.opt.completeopt = "menu,menuone,noselect" +vim.opt.mouse = '' +vim.opt.shortmess = vim.o.shortmess .. "c" + +vim.opt.cursorline = true +vim.opt.undofile = true + +vim.opt.spelllang = 'de' + +vim.opt.termguicolors = true +vim.opt.pumblend = 10 + +vim.opt.updatetime = 300 + +local command = vim.api.nvim_create_user_command +local initlua = vim.fn.stdpath('config') .. '/init.lua' +command('RC', function() vim.cmd.edit(initlua) end, { desc = 'edit init.lua' }) +command('CD', ':cd %:h', { desc = 'cd to current file' }) +command('TrailingSpace', '%s/\\s*$//g', { desc = 'remove trailing spaces' }) + +vim.g.tex_flavor = 'latex' + +local key = vim.keymap.set + +key('n', '', 'za', { desc = 'toggle fold' }) +key('v', '.', 'normal .', { desc = 'repeat last command in visual mode' }) +key('n', 'cy', '"*y', { desc = 'copy to system clipboard' }) + +key('t', '', '', { desc = 'exit terminal mode' }) + +-- Arrow keys for window movement and resizing +key('n', '', 'h') +key('n', '', 'j') +key('n', '', 'k') +key('n', '', 'l') +-- +key('n', '', "',<") +key('n', '', "',>',") +key('n', '', "',-") +key('n', '', "',+") + +key('n', '', function() vim.fn.search('^[^[:space:])\\]}]', 'be') end, { desc = 'jump to previous unindented line' }) +key('n', '', function() vim.fn.search('^[^[:space:])\\]}]', 'e') end, { desc = 'jump to next unindented line' }) + +key('i', '', 'u') +key('n', '&', ':&&') +key('x', '&', ':&&') +key('n', 'Y', 'y$') + + +key('i', '', '', { desc = 'completion' }) +key('n', '', 'nohredraw!', { desc = 'clear search highlight' }) +key('v', 'gs', "'<,'>sort", { desc = 'sort selection' }) + + +key({ 'n', 'x' }, '', "(EasyAlign)", { desc = 'align selection' }) diff --git a/init.vim b/init.vim deleted file mode 100644 index fddbedf..0000000 --- a/init.vim +++ /dev/null @@ -1,193 +0,0 @@ -if exists("$VIRTUAL_ENV") - let g:python3_host_prog=substitute(system("which -a python3 | head -n2 | tail -n1"), "\n", '', 'g') -else - let g:python3_host_prog=substitute(system("which python3"), "\n", '', 'g') -endif - -runtime packages.vim - -let $MYVIMDIR=split(&rtp, ',')[0] - -set exrc - -set background=dark -let g:chroma_italic_style="bold" -let g:chroma_nontext_dark=1 -colo chroma - -if exists("&cc") - set cc=+1 -endif - -set number - -set textwidth=80 -set tabstop=2 -set shiftwidth=2 - -set whichwrap+=<,>,h,l - -set notimeout -set ttimeout -set ttimeoutlen=50 - -set foldmethod=syntax -set foldlevelstart=99 - -" disables visualbell -set vb t_vb= - -set shellcmdflag=-c -set shell=/bin/zsh - -set modeline -set showcmd - -set ignorecase smartcase -set inccommand=split -set wildmode=list:longest,list:full -set wildignore+=*.so,*.swp,*.zip,*.o -set suffixes=.bak,~,.h,.info,.swp,.obj,.info,.aux,.dvi,.bbl,.out,.o,.lo,\.class -set suffixes+=.pdf -set wildmenu -set hidden - -"set completeopt=menu,noinsert,preview -"set completeopt=menuone,noinsert,noselect -set completeopt=menu,menuone,noselect -set shortmess+=c -inoremap pumvisible() ? "\" : "\u\" - -set mouse= - -set cursorline -set guicursor= - -set undofile -set undodir=~/.local/share/nvim/undo - -set spelllang=de - -set termguicolors -set pumblend=20 - -set updatetime=300 - -" custom commands -command! RC edit $MYVIMRC -command! SRC source $MYVIMRC -command! CD :cd %:h -command! PlugEdit edit $MYVIMDIR/packages.vim -command! PlugReload source $MYVIMDIR/packages.vim | PlugInstall -command! TrailingSpace %s/\s*$//g - - -"{{{ latex - -" controls filetype setting, therefore not possible to move to ftplugin -let g:tex_flavor = "latex" - -"}}} - -" {{{ misc Autocommands -augroup Misc - au FileType mail setlocal spell - au FileType man setlocal nonu -augroup END - - -augroup Cache - autocmd! - autocmd BufRead,BufNewFile ~/Private/* setlocal directory=. -augroup END - -"{{{ binary editing -augroup Binary - au! - au BufReadPre *.bin let &bin=1 - au BufReadPost *.bin if &bin | %!xxd - au BufReadPost *.bin set ft=xxd | endif - au BufWritePre *.bin if &bin | %!xxd -r - au BufWritePre *.bin endif - au BufWritePost *.bin if &bin | %!xxd - au BufWritePost *.bin set nomod | endif -augroup END -"}}} - -"}}} - -" common mappings {{{ - -nnoremap za -vnoremap . normal . -noremap cy "*y - -tnoremap - -map h -map j -map k -map l - -map < -map > -map - -map + - -" navigate windows with alt+[hjkl] -tnoremap h -tnoremap j -tnoremap k -tnoremap l -inoremap h -inoremap j -inoremap k -inoremap l -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -nnoremap :call search('^[^[:space:])\]}]', 'be') -nnoremap :call search('^[^[:space:])\]}]', 'e') - -inoremap u -nnoremap & :&& -xnoremap & :&& -nnoremap Y y$ - -inoremap - -nmap nohredraw! - -nmap -imap - -vmap gs '<,'>sort - -"}}} - - -"Git {{{ -nmap gu Gina push -nmap gvc !git svn dcommit -nmap gvf !git svn fetch -" Git }}} - -" Start interactive EasyAlign in visual mode (e.g. vipga) -xmap (EasyAlign) - -" Start interactive EasyAlign for a motion/text object (e.g. gaip) -nmap (EasyAlign) - -let g:signify_vcs_list = [ 'git', 'hg' ] -"let g:signify_disable_by_default = 1 - - -let g:localvimrc_whitelist='/home/crater2150/work/.*' -let g:localvimrc_sandbox=0 - -set foldmethod=expr -set foldexpr=nvim_treesitter#foldexpr() -set nofoldenable " Disable folding at startup. -" vi:foldmethod=marker sw=2 diff --git a/lua/common.lua b/lua/common.lua new file mode 100644 index 0000000..7a25f61 --- /dev/null +++ b/lua/common.lua @@ -0,0 +1,61 @@ +-- Adapted from https://github.com/LazyVim/LazyVim/ +-- SPDX-License-Identifier: Apache-2.0 +return { + icons = { + dap = { + Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", + BreakpointCondition = " ", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", + }, + diagnostics = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + }, + git = { + added = " ", + modified = " ", + removed = " ", + }, + kinds = { + Array = " ", + Boolean = " ", + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = " ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = " ", + Module = " ", + Namespace = " ", + Null = " ", + Number = " ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = " ", + Variable = " ", + }, + }, +} diff --git a/lua/plugins/chroma.lua b/lua/plugins/chroma.lua new file mode 100644 index 0000000..daad375 --- /dev/null +++ b/lua/plugins/chroma.lua @@ -0,0 +1,5 @@ +return { + 'crater2150/vim-theme-chroma', + lazy = false, priority = 1000, + config = function() vim.cmd.colorscheme("chroma") end +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..5de5c8d --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,65 @@ +return { + "hrsh7th/nvim-cmp", + -- load cmp on InsertEnter + event = "InsertEnter", + -- these dependencies will only be loaded when cmp loads + -- dependencies are always lazy-loaded unless specified otherwise + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-vsnip', + 'hrsh7th/vim-vsnip', + 'hrsh7th/vim-vsnip-integ', + 'onsails/lspkind.nvim', + }, + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') + + cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = "copilot"}, + },{ + { name = 'buffer' }, + --{ name = 'path' }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + symbol_map = { Copilot = "" }, + }) + }, + }) + end, +} diff --git a/lua/plugins/deepl.lua b/lua/plugins/deepl.lua new file mode 100644 index 0000000..2ee6c3d --- /dev/null +++ b/lua/plugins/deepl.lua @@ -0,0 +1,12 @@ +return { 'ryicoh/deepl.vim', + keys = { + + { '', function() vim.fn['deepl#v']("EN") end, mode = 'v' }, + { '', function() vim.fn['deepl#v']("DE") end, mode = 'v' }, + }, + dependencies = { 'tsuyoshicho/vim-pass' }, + config = function () + vim.g['deepl#endpoint'] = "https://api-free.deepl.com/v2/translate" + vim.g['deepl#auth_key'] = vim.fn['pass#get']('web/deepl.com', 'apikey') + end +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..efd9714 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,64 @@ +return { + "folke/which-key.nvim", + 'pbrisbin/vim-mkdir', + 'fladson/vim-kitty', + + 'tpope/vim-repeat', + 'tpope/vim-surround', + 'tpope/vim-characterize', + 'tpope/vim-eunuch', + 'tpope/vim-commentary', + 'tpope/vim-sleuth', + + -- ic / ac + {'glts/vim-textobj-comment', + dependencies = { 'kana/vim-textobj-user' } + }, + -- ii / ai + 'michaeljsmith/vim-indent-object', + 'airblade/vim-gitgutter', + + 'neovim/nvim-lspconfig', + + { 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + + { 'ray-x/lsp_signature.nvim', + config = function() + require('lsp_signature').setup({}) + end + }, + 'nvim-lua/lsp-status.nvim', + 'kyazdani42/nvim-web-devicons', + 'folke/trouble.nvim', + 'folke/lsp-colors.nvim', + 'nvim-lua/popup.nvim', + + 'zbirenbaum/copilot.lua', + {'zbirenbaum/copilot-cmp', + dependencies = { "hrsh7th/nvim-cmp" }, + }, + 'junegunn/vim-easy-align', + 'machakann/vim-highlightedyank', + 'vim-airline/vim-airline', + 'lukas-reineke/indent-blankline.nvim', + 'lambdalisue/suda.vim', + -- git + 'lambdalisue/gina.vim', + 'gregsexton/gitv', + 'gisphm/vim-gitignore', + 'sjl/splice.vim', + 'jamessan/vim-gnupg', + + 'lervag/vimtex', + 'ledger/vim-ledger', + 'anekos/hledger-vim', + + 'vim-pandoc/vim-pandoc', + 'vim-pandoc/vim-pandoc-syntax', + 'isobit/vim-caddyfile', + 'GEverding/vim-hocon', + 'nfnty/vim-nftables', +} +-- 'powerman/vim-plugin-AnsiEsc', diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..147bec8 --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,200 @@ +return { + -- lspconfig + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { "folke/neoconf.nvim", cmd = "Neoconf", config = true }, + { "folke/neodev.nvim", opts = {} }, + "mason.nvim", + "williamboman/mason-lspconfig.nvim", + { + "hrsh7th/cmp-nvim-lsp", + cond = function() + return require("lazy.core.config").plugins["nvim-cmp"] ~= nil + end, + }, + }, + ---@class PluginLspOpts + opts = { + -- options for vim.diagnostic.config() + diagnostics = { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + -- this will set set the prefix to a function that returns the diagnostics icon based on the severity + -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported + -- prefix = "icons", + }, + severity_sort = true, + }, + -- add any global capabilities here + capabilities = {}, + servers = { + jsonls = {}, + lua_ls = { + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + callSnippet = "Replace", + }, + telemetry = { enable = false }, + }, + }, + }, + pylsp = { + settings = { + pylsp = { + plugins = { + rope_autoimport = { enabled = true, }, + isort = { enabled = true, }, + } + } + } + } + }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + -- tsserver = function(_, opts) + -- require("typescript").setup({ server = opts }) + -- return true + -- end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + }, + }, + ---@param opts PluginLspOpts + config = function(_, opts) + -- diagnostics + for name, icon in pairs(require("common").icons.diagnostics) do + name = "DiagnosticSign" .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) + end + + if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then + opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●" + or function(diagnostic) + local icons = require("common").icons.diagnostics + for d, icon in pairs(icons) do + if diagnostic.severity == vim.diagnostic.severity[d:upper()] then + return icon + end + end + end + end + + vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) + + local servers = opts.servers + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities(), + opts.capabilities or {} + ) + + local function setup(server) + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then + return + end + elseif opts.setup["*"] then + if opts.setup["*"](server, server_opts) then + return + end + end + require("lspconfig")[server].setup(server_opts) + end + + -- get all the servers that are available thourgh mason-lspconfig + local have_mason, mlsp = pcall(require, "mason-lspconfig") + local all_mslp_servers = {} + if have_mason then + all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) + end + + local ensure_installed = {} ---@type string[] + for server, server_opts in pairs(servers) do + if server_opts then + server_opts = server_opts == true and {} or server_opts + -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig + if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + end + + if have_mason then + mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) + end + end, + }, + + -- formatters + { + "jose-elias-alvarez/null-ls.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "mason.nvim" }, + opts = function() + local nls = require("null-ls") + return { + root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), + sources = { + nls.builtins.formatting.stylua, + nls.builtins.formatting.shfmt, + nls.builtins.completion.vsnip, + nls.builtins.diagnostics.zsh, + nls.builtins.formatting.beautysh, + }, + } + end, + }, + + -- cmdline tools and lsp servers + { + "williamboman/mason.nvim", + cmd = "Mason", + opts = { + ensure_installed = { + "jdtls", + "lua-language-server", + }, + }, + ---@param opts MasonSettings | {ensure_installed: string[]} + config = function(_, opts) + require("mason").setup(opts) + local mr = require("mason-registry") + local function ensure_installed() + for _, tool in ipairs(opts.ensure_installed) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end + end + if mr.refresh then + mr.refresh(ensure_installed) + else + ensure_installed() + end + end, + }, + 'mfussenegger/nvim-jdtls', +} + diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..77a4522 --- /dev/null +++ b/lua/plugins/markdown.lua @@ -0,0 +1,4 @@ +return { + 'euclio/vim-markdown-composer', + build = 'cargo build --release' +} diff --git a/lua/plugins/metals.lua b/lua/plugins/metals.lua new file mode 100644 index 0000000..8cc94b5 --- /dev/null +++ b/lua/plugins/metals.lua @@ -0,0 +1,58 @@ +return { + 'scalameta/nvim-metals', + dependencies = { + 'nvim-lua/plenary.nvim', + 'mfussenegger/nvim-dap', + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + local metals_config = require('metals').bare_config() + metals_config.init_options.statusBarProvider = "on" + metals_config.settings = { + showImplicitArguments = true, + superMethodLensesEnabled = true, + } + metals_config.on_attach = function(client, bufnr) + require("metals").setup_dap() + require("my_lsp").on_attach(client, bufnr) + end + metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() + -- Debug settings if you're using nvim-dap + local dap = require("dap") + dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "RunOrTest", + metals = { + runType = "runOrTestFile", + --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, + } + + + -- Autocmd that will actually be in charging of starting the whole thing + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + -- NOTE: You may or may not want java included here. You will need it if you + -- want basic Java support but it may also conflict if you are using + -- something like nvim-jdtls which also works on a java filetype autocmd. + pattern = { "scala", "sbt" }, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + + return metals_config + end +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..d1b69f8 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,54 @@ +--Plug 'nvim-telescope/telescope.nvim' + +--Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +--Plug 'gbrlsnchs/telescope-lsp-handlers.nvim' +--Plug 'nvim-telescope/telescope-ui-select.nvim' +return { + "nvim-telescope/telescope.nvim", + dependencies = { + {'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + }, + 'gbrlsnchs/telescope-lsp-handlers.nvim', + 'nvim-telescope/telescope-ui-select.nvim', +--Plug { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } + }, + cmd = "Telescope", + version = false, + keys = { + {',ff', require("telescope.builtin").fd, desc = "Find files"}, + {',fg', require("telescope.builtin").git_files, desc = "Find files (git)"}, + {',gs', require("telescope.builtin").git_status, desc = "Git status"}, + {',s', require("telescope.builtin").lsp_dynamic_workspace_symbols, desc = "Symbols"}, + {'g/', require("telescope.builtin").live_grep, desc = "Live grep"}, + {'', require("telescope.builtin").current_buffer_fuzzy_find, desc = "Fuzzy find"}, + {'*', require("telescope.builtin").grep_string, desc = "Find at cursor"}, + {'gb', require("telescope.builtin").buffers}, + { ":", require("telescope.builtin").command_history, desc = "Command History" }, + { ";", require("telescope.builtin").commands, desc = "Commands" }, + }, + opts = { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + ["ui-select"] = { + require("telescope.themes").get_dropdown { } + }, + }, + }, + config = function(_, opts) + local telescope = require('telescope') + telescope.setup(opts) + telescope.load_extension('fzf') + telescope.load_extension('ui-select') + end, + } diff --git a/lua/plugins/text-to-color.lua b/lua/plugins/text-to-color.lua new file mode 100644 index 0000000..ef20908 --- /dev/null +++ b/lua/plugins/text-to-color.lua @@ -0,0 +1,12 @@ +return { + 'svermeulen/text-to-colorscheme', + dependencies = { 'tsuyoshicho/vim-pass' }, + config = function () + require('text-to-colorscheme').setup { + ai = { + gpt_model = "gpt-3.5-turbo", + openai_api_key = vim.fn['pass#get']('apikeys/openai_vim'), + }, + } + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..8f77982 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,88 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + version = false, -- last release is way too old and doesn't work on Windows + build = ":TSUpdate", + event = { "BufReadPost", "BufNewFile" }, + dependencies = { + { + "nvim-treesitter/nvim-treesitter-textobjects", + init = function() + -- PERF: no need to load the plugin, if we only need its queries for mini.ai + local plugin = require("lazy.core.config").spec.plugins["nvim-treesitter"] + local opts = require("lazy.core.plugin").values(plugin, "opts", false) + local enabled = false + if opts.textobjects then + for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do + if opts.textobjects[mod] and opts.textobjects[mod].enable then + enabled = true + break + end + end + end + if not enabled then + require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") + end + end, + }, + }, + keys = { + { "", desc = "Increment selection" }, + { "", desc = "Decrement selection", mode = "x" }, + }, + ---@type TSConfig + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + "bash", + "gitignore", + "html", + "java", + "json", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "scala", + "tsx", + "typescript", + "vim", + "vimdoc", + "yaml", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }, + ---@param opts TSConfig + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + ---@type table + local added = {} + opts.ensure_installed = vim.tbl_filter(function(lang) + if added[lang] then + return false + end + added[lang] = true + return true + end, opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + end, + }, + { 'nvim-treesitter/playground', + cmd = 'TSPlaygroundToggle' + }, + +} diff --git a/packages.vim b/packages.vim deleted file mode 100644 index 04ef77a..0000000 --- a/packages.vim +++ /dev/null @@ -1,125 +0,0 @@ -call plug#begin(expand(':p:h') . '/plugged') - -" basic stuff -Plug 'pbrisbin/vim-mkdir' -Plug 'embear/vim-localvimrc' - -Plug 'crater2150/vim-theme-chroma' -"Plug '~/sources/chroma-colors/vim' -Plug 'fladson/vim-kitty' - -" generic -Plug 'ryicoh/deepl.vim' -Plug 'tsuyoshicho/vim-pass' - -" tim pope stuff -Plug 'tpope/vim-repeat' " . for commands from plugins -Plug 'tpope/vim-surround' " add/remove braces,quotes,... -Plug 'tpope/vim-characterize' " More info in ga output -Plug 'tpope/vim-eunuch' " :Delete, :Move, etc. -Plug 'tpope/vim-commentary' " gc operator -Plug 'tpope/vim-sleuth' " detect shiftwidth/expandtab -" -" motions and textobjects -Plug 'kana/vim-textobj-user' | Plug 'glts/vim-textobj-comment' " ic / ac -Plug 'michaeljsmith/vim-indent-object' -Plug 'vim-scripts/argtextobj.vim' - -Plug 'airblade/vim-gitgutter' - -" LSP -Plug 'neovim/nvim-lspconfig' -Plug 'hrsh7th/cmp-buffer' -Plug 'hrsh7th/cmp-nvim-lsp' -Plug 'hrsh7th/cmp-path' -Plug 'hrsh7th/cmp-cmdline' -Plug 'hrsh7th/cmp-vsnip' -Plug 'hrsh7th/nvim-cmp' -Plug 'hrsh7th/vim-vsnip' -Plug 'hrsh7th/vim-vsnip-integ' -Plug 'nvim-lua/plenary.nvim' -Plug 'scalameta/nvim-metals' -Plug 'williamboman/mason.nvim' -Plug 'williamboman/mason-lspconfig.nvim' -Plug 'onsails/lspkind.nvim' - - -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'nvim-lua/lsp-status.nvim' -Plug 'kyazdani42/nvim-web-devicons' -Plug 'folke/trouble.nvim' -Plug 'folke/lsp-colors.nvim' -Plug 'nvim-lua/popup.nvim' -Plug 'nvim-lua/plenary.nvim' -Plug 'nvim-telescope/telescope.nvim' -Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } -Plug 'gbrlsnchs/telescope-lsp-handlers.nvim' -Plug 'nvim-telescope/telescope-ui-select.nvim' -Plug 'ray-x/lsp_signature.nvim' -Plug 'mfussenegger/nvim-jdtls' - -Plug 'mfussenegger/nvim-dap' - -Plug 'zbirenbaum/copilot.lua' -Plug 'zbirenbaum/copilot-cmp' - -Plug 'machakann/vim-highlightedyank' - -Plug 'junegunn/vim-easy-align' - -" for stuff installed via disto package manager, e.g. fzf's bundled vim plugin -Plug '/usr/share/vim/vimfiles' - -Plug 'vim-airline/vim-airline' -Plug 'lambdalisue/suda.vim' - -Plug 'vim-scripts/SyntaxRange' - -Plug 'lukas-reineke/indent-blankline.nvim' - -" ruby -Plug 'depuracao/vim-rdoc' -Plug 'vim-ruby/vim-ruby' -Plug 'tpope/vim-rails' -Plug 'tpope/vim-rake' - -" git -Plug 'lambdalisue/gina.vim' -Plug 'gregsexton/gitv' -Plug 'gisphm/vim-gitignore' -Plug 'sjl/splice.vim' - - -" other filetype specific plugins -Plug 'jamessan/vim-gnupg' -let g:no_cecutil_maps = 1 -Plug 'powerman/vim-plugin-AnsiEsc' -Plug 'tpope/vim-markdown' -Plug 'lervag/vimtex' -" let g:vimtex_compiler_method = 'arara' -Plug 'ledger/vim-ledger' -Plug 'anekos/hledger-vim' -Plug 'elzr/vim-json' -Plug 'kchmck/vim-coffee-script' -Plug 'gre/play2vim' -Plug 'isobit/vim-caddyfile' -Plug 'vim-pandoc/vim-pandoc' -Plug 'vim-pandoc/vim-pandoc-syntax' -Plug 'GEverding/vim-hocon' -Plug 'nfnty/vim-nftables' - -function! BuildComposer(info) - if a:info.status != 'unchanged' || a:info.force - if has('nvim') - !cargo build --release - else - !cargo build --release --no-default-features --features json-rpc - endif - endif -endfunction - -Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer') } - -call plug#end() - -" vim:ft=vim foldmethod=marker diff --git a/plugin/on-attach.lua b/plugin/on-attach.lua new file mode 100644 index 0000000..0fe3a52 --- /dev/null +++ b/plugin/on-attach.lua @@ -0,0 +1,46 @@ +local on_attach = function(args) + local bufnr = args.buf + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + --Enable completion triggered by + vim.bo[bufnr].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Mappings. + local opts = { silent = true, buffer = bufnr } + local loud = { buffer = bufnr } + + local map = vim.keymap.set + -- See `:help vim.lsp.*` for documentation on any of the below functions + map("n", "dr", function() require("dap").repl.toggle() end, { silent = true }) + map('n', 'gD', vim.lsp.buf.declaration, opts) + map('n', 'gd', vim.lsp.buf.definition, opts) + map('n', 'K', vim.lsp.buf.hover, opts) + map('v', 'K', vim.lsp.buf.hover, opts) + map('n', 'gi', vim.lsp.buf.implementation, opts) + map('n', '', vim.lsp.buf.signature_help, opts) + map('n', 'D', vim.lsp.buf.type_definition, opts) + map('n', 'rn', vim.lsp.buf.rename, opts) + map('n', '', vim.lsp.buf.code_action, loud) + map('n', '', vim.lsp.codelens.run, loud) + map('n', 'gr', vim.lsp.buf.references, opts) + map('n', '', vim.diagnostic.open_float, opts) + map('n', '[d', vim.diagnostic.goto_prev, opts) + map('n', ']d', vim.diagnostic.goto_next, opts) + map('n', '', vim.diagnostic.setloclist, opts) + map("n", "f", function() vim.lsp.buf.format { async = true } end, opts) + map("n", "dc", function() require("dap").continue() end, opts) + map("n", "dK", function() require("dap.ui.widgets").hover() end, opts) + map("n", "dt", function() require("dap").toggle_breakpoint() end, opts) + map("n", "dso", function() require("dap").step_over() end, opts) + map("n", "dsi", function() require("dap").step_into() end, opts) + map("n", "dl", function() require("dap").run_last() end, opts) + + map("n", "aa", vim.diagnostic.setqflist, opts) + map("n", "aw", function() vim.diagnostic.setqflist({ severity = "W" }) end, opts) + map("n", "ae", function() vim.diagnostic.setqflist({ severity = "E" }) end, opts) + + vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]] + vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float({max_width = 100, focusable = false})]] +end + +vim.api.nvim_create_autocmd("LspAttach", { callback = on_attach }) diff --git a/syntax/tolua.vim b/syntax/tolua.vim deleted file mode 100644 index 33c1ced..0000000 --- a/syntax/tolua.vim +++ /dev/null @@ -1,41 +0,0 @@ -if exists("b:current_syntax") - finish -endif - -syn include @EmbeddedLua syntax/lua.vim -syn include @EmbeddedPreproc syntax/c.vim - -syn match toluaString "\".*\"" -syn match toluaInclude "<.*>" -syn region toluaEmbeddedLua matchgroup=toluaEmbeddedDelimiter - \ start="^\$\[" end="^\$\]" contains=@EmbeddedLua -syn match toluaCInclude "^\$#.*$" contains=toluaString,toluaInclude - -syn keyword toluaStatement module nextgroup=toluaModuleName skipwhite -syn match toluaModuleName "[_a-zA-Z]\+" contained - -syn match toluaRename "@ [_a-zA-Z]\+" - -" from c syntax file -syn keyword cType int long short char void -syn keyword cType signed unsigned float double -syn keyword luaState lua_State - -syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend -syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend -syn keyword cStructure struct union enum typedef -syn keyword cStorageClass static register auto volatile extern const - -let b:current_syntax = "tolua" - -hi def link toluaEmbeddedDelimiter Special -hi def link toluaCInclude PreProc -hi def link toluaString String -hi def link toluaInclude String -hi def link toluaStatement Statement -hi def link toluaModuleName Identifier -hi def link toluaRename Special -hi def link cType Type -hi def link luaState Type -hi def link cStorageClass StorageClass -hi def link cStructure Structure