diff --git a/init.lua b/init.lua index 29a1353..b653f6e 100644 --- a/init.lua +++ b/init.lua @@ -5,476 +5,481 @@ vim.g.user_emmet_install_global = 0 vim.g.user_emmet_leader_key = "," vim.g.maplocalleader = ' ' -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({ - -- Git related plugins - 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - { - -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - { - 'j-hui/fidget.nvim', - tag = 'legacy', - opts = { - align = { - bottom = false, - }, - window = { - blend = 0, - -- border = "rounded", - }, - }, - }, - - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, - }, - }, - }, - }, - - - -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, - { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) - vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, - { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) - vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, - { buffer = bufnr, desc = '[P]review [H]unk' }) - end, - }, - }, - - - { - -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` - main = 'ibl', - opts = {}, - }, - { - "ray-x/lsp_signature.nvim", - event = "VeryLazy", - opts = {}, - config = function(_, opts) require'lsp_signature'.setup(opts) end - }, - - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - - { "nvim-treesitter/nvim-treesitter-context", opts = {} }, - - -- Fuzzy Finder (files, lsp, etc) - { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } }, - - { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - config = function(_, opts) - vim.filetype.add { - extension = { rasi = 'rasi' }, - pattern = { - ['.*/waybar/config'] = 'jsonc', - ['.*/kitty/*.conf'] = 'bash', - ['.*/hypr/.*%.conf'] = 'hyprlang', - }, - } - end - }, - - require 'kickstart.plugins.autoformat', - require 'kickstart.plugins.debug', - - { import = 'custom.plugins' }, -}, {}) - --- Set highlight on search -vim.o.hlsearch = false - --- Make line numbers default -vim.wo.number = true - --- Enable mouse mode -vim.o.mouse = 'a' - -vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' -end) - --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true - --- Keymaps for better default experience -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- [[ Highlight on yank ]] -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) - --- [[ Configure Telescope ]] -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, - pickers = { - find_files = { - theme = "ivy", - } - }, - extensions = { - -- file_browser = { - -- initial_mode = "normal", - -- theme = "ivy", - -- hijack_netrw = true - -- }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', 'sb', 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 = 0, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'rg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` -require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'go', 'lua', 'python', 'tsx', 'typescript', 'markdown', 'bash', 'html', 'css' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = true, - - highlight = { enable = true }, - -- indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, -} - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - --- [[ Configure LSP ]] --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) - - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( - vim.lsp.handlers.hover, { - border = "single" - } - ) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( - vim.lsp.handlers.signatureHelp, { - border = "single" - } - ) - vim.diagnostic.config({ float = { border = "single" } }) -end -local mason_registry = require('mason-registry') -local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. - '/node_modules/@vue/language-server' -local servers = { - ocamllsp = {}, - - ts_ls = { - init_options = { - plugins = { - { - name = '@vue/typescript-plugin', - location = vue_language_server_path, - languages = { 'vue' }, - }, - }, - }, - filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, - }, - - gopls = { - gopls = { - usePlaceholders = true, - analyses = { - unusedparams = true, - } - }, - }, - html = { provideFormatter = false, filetypes = {"html", "htmldjango", "php"} }, - cssls = {}, - pyright = { - settings = { - pyright = { - disableOrganizeImports = false, - }, - python = { - analysis = { - diagnosticMode = "workspace" - } - } - } - }, - - jdtls = { - java = { - configuration = { - runtimes = { - name = "JavaSE-17", - path = "/usr/lib/jvm/java-17-openjdk", - default = true, - } - } - } - }, - - volar = { - init_options = { - vue = { - hybridMode = true, - }, - }, - - phpactor = { - -- init_options = { - -- language_server_phpstan.enabled = false, - -- language_server_psalm.enabled = false, - -- }, - }, - - ts_ls = { - init_options = { - plugins = { - { - name = '@vue/typescript-plugin', - location = vue_language_server_path, - languages = { 'vue', "typescript", "javascript" }, - }, - }, - }, - filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, - }, - - lua_ls = { - Lua = { - workspace = { checkThirdParty = true }, - telemetry = { enable = false }, - }, - }, -}} - --- nvim-cmp supports additional completion capabilities, so broadcast that to servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) -capabilities.textDocument.completion.completionItem.snippetSupport = true - -require('mason').setup() - -local ensure_installed = vim.tbl_keys(servers or {}) -vim.list_extend(ensure_installed, { - 'stylua', - 'black', - 'prettierd', - 'gofumpt', - 'goimports-reviser', - 'golines', - 'golangci-lint', - 'ruff', - 'phpcbf', -}) -require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - -require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, -} - - -local manual_servers = { - texlab = {}, - - rust_analyzer = { - settings = { - ['rust_analyzer'] = { - cargo = { - allFeatures = true, - } - } - } - } -} - -for server_name, config in pairs(manual_servers) do - config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) - require('lspconfig')[server_name].setup(config) -end - -- this is for my personal config, i cant bother seeing every TJ's default and changing it to my own require("jabuxas") + +if not vim.g.vscode then + 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({ + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + { + 'j-hui/fidget.nvim', + tag = 'legacy', + opts = { + align = { + bottom = false, + }, + window = { + blend = 0, + -- border = "rounded", + }, + }, + }, + + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + }, + }, + + + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, + { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) + vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, + { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) + vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, + { buffer = bufnr, desc = '[P]review [H]unk' }) + end, + }, + }, + + + { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + main = 'ibl', + opts = {}, + }, + { + "ray-x/lsp_signature.nvim", + event = "VeryLazy", + opts = {}, + config = function(_, opts) require'lsp_signature'.setup(opts) end + }, + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + { "nvim-treesitter/nvim-treesitter-context", opts = {} }, + + -- Fuzzy Finder (files, lsp, etc) + { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } }, + + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + + { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', + config = function(_, opts) + vim.filetype.add { + extension = { rasi = 'rasi' }, + pattern = { + ['.*/waybar/config'] = 'jsonc', + ['.*/kitty/*.conf'] = 'bash', + ['.*/hypr/.*%.conf'] = 'hyprlang', + }, + } + end + }, + + require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.debug', + + { import = 'custom.plugins' }, + }, {}) + + -- Set highlight on search + vim.o.hlsearch = false + + -- Make line numbers default + vim.wo.number = true + + -- Enable mouse mode + vim.o.mouse = 'a' + + vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' + end) + + -- Enable break indent + vim.o.breakindent = true + + -- Save undo history + vim.o.undofile = true + + -- Case-insensitive searching UNLESS \C or capital in search + vim.o.ignorecase = true + vim.o.smartcase = true + + -- Keep signcolumn on by default + vim.wo.signcolumn = 'yes' + + -- Decrease update time + vim.o.updatetime = 250 + vim.o.timeoutlen = 300 + + -- Set completeopt to have a better completion experience + vim.o.completeopt = 'menuone,noselect' + + -- NOTE: You should make sure your terminal supports this + vim.o.termguicolors = true + + -- Keymaps for better default experience + vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + + -- Remap for dealing with word wrap + vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + + -- [[ Highlight on yank ]] + local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) + vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', + }) + + -- [[ Configure Telescope ]] + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + pickers = { + find_files = { + theme = "ivy", + } + }, + extensions = { + -- file_browser = { + -- initial_mode = "normal", + -- theme = "ivy", + -- hijack_netrw = true + -- }, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', 'sb', 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 = 0, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'rg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + + -- [[ Configure Treesitter ]] + -- See `:help nvim-treesitter` + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'go', 'lua', 'python', 'tsx', 'typescript', 'markdown', 'bash', 'html', 'css' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + + highlight = { enable = true }, + -- indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + + -- Diagnostic keymaps + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) + vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) + vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + + -- [[ Configure LSP ]] + -- This function gets run when an LSP connects to a particular buffer. + local on_attach = function(_, bufnr) + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) + + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( + vim.lsp.handlers.hover, { + border = "single" + } + ) + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signatureHelp, { + border = "single" + } + ) + vim.diagnostic.config({ float = { border = "single" } }) + end + local mason_registry = require('mason-registry') + local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. + '/node_modules/@vue/language-server' + local servers = { + ocamllsp = {}, + + ts_ls = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue' }, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, + }, + + gopls = { + gopls = { + usePlaceholders = true, + analyses = { + unusedparams = true, + } + }, + }, + html = { provideFormatter = false, filetypes = {"html", "htmldjango", "php"} }, + cssls = {}, + pyright = { + settings = { + pyright = { + disableOrganizeImports = false, + }, + python = { + analysis = { + diagnosticMode = "workspace" + } + } + } + }, + + jdtls = { + java = { + configuration = { + runtimes = { + name = "JavaSE-17", + path = "/usr/lib/jvm/java-17-openjdk", + default = true, + } + } + } + }, + + volar = { + init_options = { + vue = { + hybridMode = true, + }, + }, + + phpactor = { + -- init_options = { + -- language_server_phpstan.enabled = false, + -- language_server_psalm.enabled = false, + -- }, + }, + + ts_ls = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue', "typescript", "javascript" }, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, + }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = true }, + telemetry = { enable = false }, + }, + }, + }} + + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + capabilities.textDocument.completion.completionItem.snippetSupport = true + + require('mason').setup() + + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', + 'black', + 'prettierd', + 'gofumpt', + 'goimports-reviser', + 'golines', + 'golangci-lint', + 'ruff', + 'phpcbf', + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + + + local manual_servers = { + texlab = {}, + + rust_analyzer = { + settings = { + ['rust_analyzer'] = { + cargo = { + allFeatures = true, + } + } + } + } + } + + for server_name, config in pairs(manual_servers) do + config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) + require('lspconfig')[server_name].setup(config) + end + require("jabuxas.nvim") +else + require "jabuxas.vscode_keymaps" +end diff --git a/lua/jabuxas/nvim.lua b/lua/jabuxas/nvim.lua new file mode 100644 index 0000000..abefae5 --- /dev/null +++ b/lua/jabuxas/nvim.lua @@ -0,0 +1,11 @@ +local keymap = vim.keymap +local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) +end +nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') +nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') +nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') diff --git a/lua/jabuxas/remap.lua b/lua/jabuxas/remap.lua index 84afdd8..19957c3 100644 --- a/lua/jabuxas/remap.lua +++ b/lua/jabuxas/remap.lua @@ -75,11 +75,8 @@ nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') -nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') -nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') -nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') diff --git a/lua/jabuxas/vscode_keymaps.lua b/lua/jabuxas/vscode_keymaps.lua new file mode 100644 index 0000000..51663bd --- /dev/null +++ b/lua/jabuxas/vscode_keymaps.lua @@ -0,0 +1,45 @@ +local keymap = vim.keymap.set +local opts = { noremap = true, silent = true } + +-- general keymaps +keymap({"n", "v"}, "t", "lua require('vscode').action('workbench.action.terminal.toggleTerminal')") +keymap({"n", "v"}, "b", "lua require('vscode').action('editor.debug.action.toggleBreakpoint')") +keymap({"n", "v"}, "d", "lua require('vscode').action('editor.action.showHover')") +keymap({"n", "v"}, "a", "lua require('vscode').action('editor.action.quickFix')") +keymap({"n", "v"}, "sp", "lua require('vscode').action('workbench.actions.view.problems')") +keymap({"n", "v"}, "cn", "lua require('vscode').action('notifications.clearAll')") +keymap({"n", "v"}, "ff", "lua require('vscode').action('workbench.action.quickOpen')") +keymap({"n", "v"}, "cp", "lua require('vscode').action('workbench.action.showCommands')") +keymap({"n"}, "rg", "lua require('vscode').action('workbench.action.findInFiles')") +keymap({"n"}, "pv", "lua require('vscode').action('workbench.explorer.fileView.toggleVisibility')") +keymap({"n"}, "sf", "Ex") +keymap({"n", "v"}, "pr", "lua require('vscode').action('code-runner.run')") +keymap({"n", "v"}, "fd", "lua require('vscode').action('editor.action.formatDocument')") + +-- harpoon keymaps +keymap({"n", "v"}, "ha", "lua require('vscode').action('vscode-harpoon.addEditor')") +keymap({"n", "v"}, "ho", "lua require('vscode').action('vscode-harpoon.editorQuickPick')") +keymap({"n", "v"}, "he", "lua require('vscode').action('vscode-harpoon.editEditors')") +keymap({"n", "v"}, "h1", "lua require('vscode').action('vscode-harpoon.gotoEditor1')") +keymap({"n", "v"}, "h2", "lua require('vscode').action('vscode-harpoon.gotoEditor2')") +keymap({"n", "v"}, "h3", "lua require('vscode').action('vscode-harpoon.gotoEditor3')") +keymap({"n", "v"}, "h4", "lua require('vscode').action('vscode-harpoon.gotoEditor4')") +keymap({"n", "v"}, "h5", "lua require('vscode').action('vscode-harpoon.gotoEditor5')") +keymap({"n", "v"}, "h6", "lua require('vscode').action('vscode-harpoon.gotoEditor6')") +keymap({"n", "v"}, "h7", "lua require('vscode').action('vscode-harpoon.gotoEditor7')") +keymap({"n", "v"}, "h8", "lua require('vscode').action('vscode-harpoon.gotoEditor8')") +keymap({"n", "v"}, "h9", "lua require('vscode').action('vscode-harpoon.gotoEditor9')") + +-- project manager keymaps +keymap({"n", "v"}, "pa", "lua require('vscode').action('projectManager.saveProject')") +keymap({"n", "v"}, "po", "lua require('vscode').action('projectManager.listProjectsNewWindow')") +keymap({"n", "v"}, "pe", "lua require('vscode').action('projectManager.editProjects')") + +-- yank to system clipboard +keymap({"n", "v"}, "y", '"+y', opts) + +-- paste from system clipboard +keymap({"n", "v"}, "p", '"+p', opts) + +-- paste preserves primal yanked piece +keymap("v", "p", '"_dP', opts)