From c37bf09c81abb538d319225a5f8c46a8832a6f4e Mon Sep 17 00:00:00 2001 From: Oluwatobi Date: Thu, 30 Nov 2023 14:57:19 +0100 Subject: [PATCH] update vim config --- after/plugin/conform-config.lua | 3 + after/plugin/dadbod-ui-config.lua | 30 ++++++ after/plugin/gopher-config.lua | 12 +++ after/plugin/telescope.lua | 39 ++++---- ftplugin/java.lua | 153 ++++++++++++++++++++++++++++++ lazy-lock.json | 38 ++++---- lua/plugins/dadbod.lua | 17 ++++ lua/plugins/gopher.lua | 7 ++ lua/thrillee/splits.lua | 8 +- 9 files changed, 267 insertions(+), 40 deletions(-) create mode 100644 after/plugin/dadbod-ui-config.lua create mode 100644 after/plugin/gopher-config.lua create mode 100644 ftplugin/java.lua create mode 100644 lua/plugins/dadbod.lua create mode 100644 lua/plugins/gopher.lua diff --git a/after/plugin/conform-config.lua b/after/plugin/conform-config.lua index 8e780f88..e2f30346 100644 --- a/after/plugin/conform-config.lua +++ b/after/plugin/conform-config.lua @@ -7,6 +7,9 @@ require('conform').setup { javascript = { { 'prettierd', 'prettier' } }, javascriptreact = { { 'prettier' } }, typescriptreact = { { 'prettier' } }, + typescript = { { 'prettier' } }, + go = { { 'gofumpt', 'goimports-reviser', 'golines' } }, + java = { 'google-java-format' }, }, } diff --git a/after/plugin/dadbod-ui-config.lua b/after/plugin/dadbod-ui-config.lua new file mode 100644 index 00000000..4b42e97d --- /dev/null +++ b/after/plugin/dadbod-ui-config.lua @@ -0,0 +1,30 @@ +vim.keymap.set('n', 'db', 'DBUIToggle', { noremap = true, desc = 'DB UI Toggle' }) +vim.keymap.set('n', 'dba', 'DBUIAddConnection', { noremap = true, desc = 'Add New DB Connection' }) + +local M = {} + +local function db_completion() + require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } } +end + +function M.setup() + vim.api.nvim_create_autocmd('FileType', { + pattern = { + 'sql', + }, + command = [[setlocal omnifunc=vim_dadbod_completion#omni]], + }) + + vim.api.nvim_create_autocmd('FileType', { + pattern = { + 'sql', + 'mysql', + 'plsql', + }, + callback = function() + vim.schedule(db_completion) + end, + }) +end + +return M diff --git a/after/plugin/gopher-config.lua b/after/plugin/gopher-config.lua new file mode 100644 index 00000000..3016172b --- /dev/null +++ b/after/plugin/gopher-config.lua @@ -0,0 +1,12 @@ +require('gopher').setup { + commands = { + go = 'go', + gomodifytags = 'gomodifytags', + gotests = '~/go/bin/gotests', -- also you can set custom command path + impl = 'impl', + iferr = 'iferr', + }, +} + +vim.keymap.set('n', 'gaj', ':GoTagAdd json', { desc = 'Add JSON Tag TO Go Struct' }) +vim.keymap.set('n', 'gax', ':GoTagAdd xml', { desc = 'Add XML Tag TO Go Struct' }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index 7aeecde6..4bbc633c 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,13 +1,13 @@ -- [[ Configure Treesitter ]] require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, }, + }, } -- Enable telescope fzf native, if installed @@ -17,11 +17,11 @@ pcall(require('telescope').load_extension, 'fzf') vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) vim.keymap.set('n', 'fb', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = true, + }) end, { desc = '[/] Fuzzily search in current buffer' }) vim.keymap.set('n', 'ff', require('telescope.builtin').find_files, { desc = 'Find [F]iles' }) @@ -29,14 +29,15 @@ vim.keymap.set('n', 'fh', require('telescope.builtin').help_tags, { desc vim.keymap.set('n', 'fw', require('telescope.builtin').grep_string, { desc = 'Find current [W]ord' }) vim.keymap.set('n', 'fd', require('telescope.builtin').diagnostics, { desc = 'Find [D]iagnostics' }) vim.keymap.set('n', 'fr', require('telescope.builtin').registers, { desc = 'Find [R]egister' }) -vim.keymap.set('n', 'fF', - function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end, - { desc = '[S]earch [R]esume' }) +vim.keymap.set('n', 'fF', function() + require('telescope.builtin').find_files { hidden = true, no_ignore = true } +end, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 'fg', require('telescope.builtin').live_grep, { desc = 'Find by [G]rep' }) vim.keymap.set('n', 'fG', function() - require("telescope.builtin").live_grep { - additional_args = function(args) return vim.list_extend(args, { "--hidden", "--no-ignore" }) end, - } + require('telescope.builtin').live_grep { + additional_args = function(args) + return vim.list_extend(args, { '--hidden', '--no-ignore' }) + end, + } end, { desc = 'Find by [G]rep In all Files' }) - diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000..785f0737 --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,153 @@ +-- Java Language Server configuration. +-- Locations: +-- 'nvim/ftplugin/java.lua'. +-- 'nvim/lang-servers/intellij-java-google-style.xml' + +local jdtls_ok, jdtls = pcall(require, 'jdtls') +if not jdtls_ok then + vim.notify 'JDTLS not found, install with `:LspInstall jdtls`' + return +end + +-- See `:help vim.lsp.start_client` for an overview of the supported `config` options. +-- local jdtls_path = vim.fn.stdpath 'data' .. '/mason/packages/jdtls' +local jdtls_path = '/Users/oluwatobibello/.local/share/nvim/mason/packages/jdtls' +local path_to_lsp_server = jdtls_path .. '/config_mac' +local path_to_plugins = jdtls_path .. '/plugins/' +local path_to_jar = path_to_plugins .. 'org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar' +local lombok_path = path_to_plugins .. 'lombok.jar' + +local root_markers = { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' } +local root_dir = require('jdtls.setup').find_root(root_markers) +if root_dir == '' then + return +end + +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name +os.execute('mkdir ' .. workspace_dir) + +local java_17_home_dir = '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home' +local java_11_home_dir = '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home' + +-- Main Config +local config = { + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + cmd = { + java_17_home_dir .. '/bin/java', + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Dlog.level=ALL', + '-javaagent:' .. lombok_path, + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + + '-jar', + path_to_jar, + '-configuration', + path_to_lsp_server, + '-data', + workspace_dir, + }, + + -- This is the default if not provided, you can remove it. Or adjust as needed. + -- One dedicated LSP server & client will be started per unique root_dir + root_dir = root_dir, + + -- Here you can configure eclipse.jdt.ls specific settings + -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + -- for a list of options + settings = { + java = { + home = java_17_home_dir, + eclipse = { + downloadSources = true, + }, + configuration = { + updateBuildConfiguration = 'interactive', + runtimes = { + { + name = 'JavaSE-11', + path = '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home', + }, + { + name = 'JavaSE-17', + path = java_17_home_dir, + }, + }, + }, + maven = { + downloadSources = true, + }, + implementationsCodeLens = { + enabled = true, + }, + referencesCodeLens = { + enabled = true, + }, + references = { + includeDecompiledSources = true, + }, + }, + signatureHelp = { enabled = true }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + importOrder = { + 'java', + 'javax', + 'com', + 'org', + }, + }, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + codeGeneration = { + toString = { + template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', + }, + useBlocks = true, + }, + }, + + flags = { + allow_incremental_sync = true, + }, + init_options = { + bundles = {}, + }, +} + +config['on_attach'] = function(_, bufnr) + require('keymaps').map_java_keys(bufnr) + require('lsp_signature').on_attach({ + bind = true, -- This is mandatory, otherwise border config won't get registered. + floating_window_above_cur_line = false, + padding = '', + handler_opts = { + border = 'rounded', + }, + }, bufnr) +end + +-- This starts a new client & server, +-- or attaches to an existing client & server depending on the `root_dir`. +require('jdtls').start_or_attach(config) diff --git a/lazy-lock.json b/lazy-lock.json index 4a5b1ea9..96778cb2 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,39 +1,43 @@ { - "LuaSnip": { "branch": "master", "commit": "80a8528f084a97b624ae443a6f50ff8074ba486b" }, + "LuaSnip": { "branch": "master", "commit": "46c91e814732c1630b8a8b50d04acbf54b8320fa" }, "alpha-nvim": { "branch": "main", "commit": "234822140b265ec4ba3203e3e0be0e0bb826dff5" }, - "catppuccin": { "branch": "main", "commit": "b359f3eec32dcc6b7c9a26901dc235bbb6cd8a0b" }, + "catppuccin": { "branch": "main", "commit": "9f3c13bbcf16fcaec3a429c03743a13e5923f3e3" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "f7766d2fbe23f0f22a3db1513beba7d03a8dc261" }, + "conform.nvim": { "branch": "master", "commit": "ca3dfba94600aa62bfc88ae37cbd4f17eaea2553" }, "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, - "lazy.nvim": { "branch": "main", "commit": "16603c6917435d8446f7357cb61095138a417085" }, + "gopher.nvim": { "branch": "main", "commit": "ac27f4b6794c872140fb205313d79ab166892fe9" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazygit.nvim": { "branch": "main", "commit": "de35012036d43bca03628d40d083f7c02a4cda3f" }, "lsp-zero.nvim": { "branch": "v1.x", "commit": "c51a9104de7fddff2351361d2dbcbd8d08600ef4" }, "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" }, - "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, - "mini.ai": { "branch": "main", "commit": "fc9ce93eb8d58ce1a39101928fb5ea8f8b97844c" }, - "mini.comment": { "branch": "main", "commit": "e4320af992cd053a7da2f33d9f63a86c2ab6ce59" }, - "mini.surround": { "branch": "main", "commit": "862cfaef72d789d320625ec34e2488a5cc8fd423" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "6eb8cae80f2e4322ec82cd9f8fa423f6d1eb02c3" }, + "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, + "mini.ai": { "branch": "main", "commit": "4a2e387b121352dfb478f440c9a5313a9d97006c" }, + "mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" }, + "mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "71f1841ba6c652908678cece623f52c1fea8a6cd" }, "nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" }, "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, - "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, - "nvim-lspconfig": { "branch": "master", "commit": "d0467b9574b48429debf83f8248d8cee79562586" }, - "nvim-treesitter": { "branch": "master", "commit": "efec7115d8175bdb6720eeb4e26196032cb52593" }, - "nvim-treesitter-context": { "branch": "master", "commit": "2806d83e3965017382ce08792ee527e708fa1bd4" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "e69a504baf2951d52e1f1fbb05145d43f236cbf1" }, + "nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "90a28fd7637b66e055af62387ecee06f7cbd3173" }, + "nvim-treesitter": { "branch": "master", "commit": "075a64addc33390028ea124a1046a43497f05cd1" }, + "nvim-treesitter-context": { "branch": "master", "commit": "c03f8aab1e6649036d69ba7e3af4d09cb7e4d977" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "92e688f013c69f90c9bbd596019ec10235bc51de" }, - "nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "6c30f3c8915d7b31c3decdfe6c7672432da1809d" }, + "nvim-web-devicons": { "branch": "master", "commit": "3fafeea5f339223e888fd15eb4032260849cb038" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, - "undotree": { "branch": "master", "commit": "170aa9e516b6926e6bddfe21bbf01f2283a00e7d" }, + "undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" }, + "vim-dadbod": { "branch": "master", "commit": "fecf5a3ecfb1869f34252c7c27351de99f01ab0e" }, + "vim-dadbod-completion": { "branch": "master", "commit": "bcdf3ff768cc7e544a0f78b0383d8719c2116569" }, + "vim-dadbod-ui": { "branch": "master", "commit": "95fd22469507e86b78aa55d868c14108adee2881" }, "vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" }, "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, diff --git a/lua/plugins/dadbod.lua b/lua/plugins/dadbod.lua new file mode 100644 index 00000000..de850af8 --- /dev/null +++ b/lua/plugins/dadbod.lua @@ -0,0 +1,17 @@ +return { + 'kristijanhusak/vim-dadbod-ui', + dependencies = { + { 'tpope/vim-dadbod', lazy = true }, + { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, + }, + cmd = { + 'DBUI', + 'DBUIToggle', + 'DBUIAddConnection', + 'DBUIFindBuffer', + }, + init = function() + -- Your DBUI configuration + vim.g.db_ui_use_nerd_fonts = 1 + end, +} diff --git a/lua/plugins/gopher.lua b/lua/plugins/gopher.lua new file mode 100644 index 00000000..b313e260 --- /dev/null +++ b/lua/plugins/gopher.lua @@ -0,0 +1,7 @@ +return { + 'olexsmir/gopher.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + }, +} diff --git a/lua/thrillee/splits.lua b/lua/thrillee/splits.lua index a241c6fd..3db3eb74 100644 --- a/lua/thrillee/splits.lua +++ b/lua/thrillee/splits.lua @@ -5,10 +5,10 @@ vim.opt.splitright = true vim.keymap.set('n', '||', 'vsplit', { desc = 'Vertical Split' }) vim.keymap.set('n', '--', 'split', { desc = 'Horinzontal Split' }) -vim.keymap.set('n', '', 'h', { desc = 'Navigate to the left' }) -vim.keymap.set('n', '', '', { desc = 'Navigate below' }) -vim.keymap.set('n', '', 'k', { desc = 'Navigate up' }) -vim.keymap.set('n', '', 'l', { desc = 'Navigate right' }) +-- vim.keymap.set('n', '', 'h', { desc = 'Navigate to the left' }) +-- vim.keymap.set('n', '', '', { desc = 'Navigate below' }) +-- vim.keymap.set('n', '', 'k', { desc = 'Navigate up' }) +-- vim.keymap.set('n', '', 'l', { desc = 'Navigate right' }) vim.keymap.set('n', 'sh', 'h', { desc = 'Navigate to the left' }) vim.keymap.set('n', 'sw', '', { desc = 'Navigate below' })