From 96b0313c36d1c113a1f5ff7ce1387e81a30fd84b Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 10 Jan 2025 18:56:19 +0100 Subject: [PATCH] Rewrite the remaining neovim config in lua --- .config/nvim/ftplugin/haskell.lua | 4 + .config/nvim/ftplugin/java.lua | 94 +++++----- .config/nvim/ftplugin/php.lua | 3 + .config/nvim/init.lua | 112 ++++++++++++ .config/nvim/lua/lspserver.lua | 77 ++++++++ .config/nvim/{init.vim => lua/plugins.lua} | 203 ++------------------- 6 files changed, 256 insertions(+), 237 deletions(-) create mode 100644 .config/nvim/ftplugin/haskell.lua create mode 100644 .config/nvim/ftplugin/php.lua create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lua/lspserver.lua rename .config/nvim/{init.vim => lua/plugins.lua} (55%) diff --git a/.config/nvim/ftplugin/haskell.lua b/.config/nvim/ftplugin/haskell.lua new file mode 100644 index 0000000..4203462 --- /dev/null +++ b/.config/nvim/ftplugin/haskell.lua @@ -0,0 +1,4 @@ +vim.bo.tabstop = 8 +vim.bo.expandtab = true +vim.bo.softtabstop = 4 +vim.bo.shiftwidth = 4 diff --git a/.config/nvim/ftplugin/java.lua b/.config/nvim/ftplugin/java.lua index 0f2af90..086aa3f 100644 --- a/.config/nvim/ftplugin/java.lua +++ b/.config/nvim/ftplugin/java.lua @@ -23,59 +23,59 @@ end -- See `:help vim.lsp.start_client` for an overview of the supported `config` options. local config = { - on_attach = on_attach, -- We pass our on_attach keybindings to the configuration map - flags = { - debounce_text_changes = 150, - }, + on_attach = on_attach, -- We pass our on_attach keybindings to the configuration map + flags = { + debounce_text_changes = 150, + }, - -- The command that starts the language server - -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line - cmd = { - 'java', + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + cmd = { + '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', - '-Xms1g', - '--add-modules=ALL-SYSTEM', - '--add-opens', 'java.base/java.util=ALL-UNNAMED', - '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + '-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', + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', - '-jar', jdtls_home .. '/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar', - '-configuration', jdtls_home .. '/config_linux', - '-data', os.getenv('HOME') .. '/.cache/jdtls/' .. project_name - }, + '-jar', jdtls_home .. '/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar', + '-configuration', jdtls_home .. '/config_linux', + '-data', os.getenv('HOME') .. '/.cache/jdtls/' .. project_name + }, - -- 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 = vim.fs.root(0, {'.git', 'mvnw', 'gradlew', 'build.gradle'}), + -- 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 = vim.fs.root(0, {'.git', 'mvnw', 'gradlew', 'build.gradle'}), - -- 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 = { - signatureHelp = { enabled = true }, - jdt = { - ls = { - androidSupport = { enabled = true }, - } - } - } - }, + -- 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 = { + signatureHelp = { enabled = true }, + jdt = { + ls = { + androidSupport = { enabled = true }, + } + } + } + }, - -- Language server `initializationOptions` - -- You need to extend the `bundles` with paths to jar files - -- if you want to use additional eclipse.jdt.ls plugins. - -- - -- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation - -- - -- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this - init_options = { - bundles = {} - }, + -- Language server `initializationOptions` + -- You need to extend the `bundles` with paths to jar files + -- if you want to use additional eclipse.jdt.ls plugins. + -- + -- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation + -- + -- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this + init_options = { + bundles = {} + } } -- This starts a new client & server, -- or attaches to an existing client & server depending on the `root_dir`. diff --git a/.config/nvim/ftplugin/php.lua b/.config/nvim/ftplugin/php.lua new file mode 100644 index 0000000..b79523b --- /dev/null +++ b/.config/nvim/ftplugin/php.lua @@ -0,0 +1,3 @@ +vim.bo.expandtab = true +vim.bo.tabstop = 4 +vim.bo.shiftwidth = 4 diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..8c1ddd0 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,112 @@ +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = false +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.ruler = true +vim.opt.backup = false +vim.opt.number = true +vim.opt.colorcolumn = "120" +vim.opt.exrc = true +vim.opt.secure = true +vim.opt.hidden = true + +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +vim.opt.shortmess:append('c') + +-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +-- delays and poor user experience. +vim.opt.updatetime = 300 + +-- Always show the signcolumn, otherwise it would shift the text each time +-- diagnostics appear/become resolved. +-- Recently vim can merge signcolumn and number column into one +vim.opt.signcolumn = 'yes' + +vim.opt.mouse = 'a' -- " Enable mouse in all modes. + +-- +-- Packer +-- +vim.cmd [[packadd packer.nvim]] + +require'packer'.startup(function() + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + use 'mfussenegger/nvim-dap' + use 'airblade/vim-gitgutter' + use 'neovim/nvim-lspconfig' + use 'dense-analysis/ale' + use 'liuchengxu/vista.vim' -- Tag bar. + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + + -- Git. + use 'tpope/vim-fugitive' + use { + 'sindrets/diffview.nvim', + requires = {'nvim-lua/plenary.nvim'} + } + + -- File browser. + use { + 'kyazdani42/nvim-tree.lua', + requires = {'nvim-tree/nvim-web-devicons'} -- optional, for file icon + } + use { + 'nvim-telescope/telescope.nvim', + requires = {'nvim-lua/plenary.nvim'} + } + use 'nvim-telescope/telescope-ui-select.nvim' + use { + 'kevinhwang91/nvim-ufo', + requires = {'kevinhwang91/promise-async'} + } + + -- Theme. + use 'qaptoR-nvim/chocolatier.nvim' + use { + 'nvim-lualine/lualine.nvim', + requires = {'nvim-tree/nvim-web-devicons'} -- optional, for status line icons + } + + -- Syntax. + use 'leafOfTree/vim-vue-plugin' + use 'mfussenegger/nvim-jdtls' + use 'dart-lang/dart-vim-plugin' + use { + 'akinsho/flutter-tools.nvim', + requires = { + 'nvim-lua/plenary.nvim' + } + } + use 'vim-vdebug/vdebug' + + -- nvim-cmp + use 'dcampos/nvim-snippy' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/nvim-cmp' + use 'dcampos/cmp-snippy' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-buffer' +end) + +require'plugins' +require'lspserver' + +-- +-- Theme +-- +vim.cmd('colorscheme chocolatier') +vim.opt.termguicolors = true + +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap = true, silent = true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) diff --git a/.config/nvim/lua/lspserver.lua b/.config/nvim/lua/lspserver.lua new file mode 100644 index 0000000..da27fdd --- /dev/null +++ b/.config/nvim/lua/lspserver.lua @@ -0,0 +1,77 @@ +require'lsphelp' +local nvim_lsp = require('lspconfig') + +nvim_lsp['hls'].setup { + on_attach = default_on_attach, + capabilities = capabilities, + flags = { + debounce_text_changes = 150, + }, + settings = { + haskell = { + plugin = { + stan = { + globalOn = false + } + } + } + } +} +nvim_lsp['intelephense'].setup { + on_attach = default_on_attach, + flags = { + debounce_text_changes = 150 + }, + init_options = { + licenceKey = os.getenv('HOME') .. '/Documents/Schluessel/intelephense.key', + storagePath = '/tmp/intelephense' + }, + capabilities = capabilities, + settings = { + intelephense = { + environment = { + phpVersion = '8.2.0' + } + } + } +} +nvim_lsp['clangd'].setup { + on_attach = default_on_attach, + capabilities = capabilities +} +require("flutter-tools").setup { + outline = { + open_cmd = "Vista" + }, + lsp = { + on_attach = default_on_attach, + capabilities = capabilities + } +} +nvim_lsp['twiggy_language_server'].setup { + on_attach = default_on_attach, + capabilities = capabilities, + settings = { + twiggy = { + framework = 'symfony', + phpExecutable = '/usr/bin/php', + symfonyConsolePath = 'bin/console', + diagnostics = { + twigCsFixer = false + } + } + } +} +vim.g.vim_vue_plugin_config = { + syntax = { + template = {'html'}, + script = {'javascript'}, + style = {'css'}, + }, + full_syntax = {}, + initial_indent = {}, + attribute = 0, + keyword = 0, + foldexpr = 0, + debug = 0 +} diff --git a/.config/nvim/init.vim b/.config/nvim/lua/plugins.lua similarity index 55% rename from .config/nvim/init.vim rename to .config/nvim/lua/plugins.lua index 00c6df2..8ef87ea 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/lua/plugins.lua @@ -1,98 +1,3 @@ -set ts=4 -set sw=4 -set noet -set ignorecase -set smartcase -set ruler -set nobackup -set number -set colorcolumn=120 -set exrc -set secure -set hidden - -"set completeopt=menuone,noinsert,noselect -set completeopt=menu,menuone,noselect -set shortmess+=c -" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable -" delays and poor user experience. -set updatetime=300 -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -" Recently vim can merge signcolumn and number column into one -set signcolumn=yes -set mouse=a " Enable mouse in all modes. - -lua << EOF -require'lsphelp' - --- --- Packer --- -vim.cmd [[packadd packer.nvim]] - -require('packer').startup(function() - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - use 'mfussenegger/nvim-dap' - use 'airblade/vim-gitgutter' - use 'neovim/nvim-lspconfig' - use 'dense-analysis/ale' - use 'liuchengxu/vista.vim' -- Tag bar. - - -- Git. - use 'tpope/vim-fugitive' - use { - 'sindrets/diffview.nvim', - requires = {'nvim-lua/plenary.nvim'} - } - - -- File browser. - use { - 'kyazdani42/nvim-tree.lua', - requires = {'nvim-tree/nvim-web-devicons'} -- optional, for file icon - } - use { - 'nvim-telescope/telescope.nvim', - requires = {'nvim-lua/plenary.nvim'} - } - use 'nvim-telescope/telescope-ui-select.nvim' - use { - 'kevinhwang91/nvim-ufo', - requires = {'kevinhwang91/promise-async'} - } - - -- Theme. - use 'EdenEast/nightfox.nvim' - - -- Status line. - use { - 'nvim-lualine/lualine.nvim', - requires = {'nvim-tree/nvim-web-devicons'} -- optional, for status line icons - } - - -- Syntax. - use 'leafOfTree/vim-vue-plugin' - use 'mfussenegger/nvim-jdtls' - use 'dart-lang/dart-vim-plugin' - use { - 'akinsho/flutter-tools.nvim', - requires = { - 'nvim-lua/plenary.nvim' - } - } - use 'vim-vdebug/vdebug' - - -- nvim-cmp - use 'dcampos/nvim-snippy' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/nvim-cmp' - use 'dcampos/cmp-snippy' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-buffer' -end) - -- -- ALE -- @@ -161,94 +66,6 @@ capabilities.textDocument.foldingRange = { lineFoldingOnly = true } --- --- LSPConfig --- -local nvim_lsp = require('lspconfig') - --- Mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions -local opts = { noremap=true, silent=true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) - -nvim_lsp['hls'].setup { - on_attach = default_on_attach, - capabilities = capabilities, - flags = { - debounce_text_changes = 150, - }, - settings = { - haskell = { - plugin = { - stan = { - globalOn = false - } - } - } - } -} -nvim_lsp['intelephense'].setup { - on_attach = default_on_attach, - flags = { - debounce_text_changes = 150 - }, - init_options = { - licenceKey = os.getenv('HOME') .. '/Documents/Schluessel/intelephense.key', - storagePath = '/tmp/intelephense' - }, - capabilities = capabilities, - settings = { - intelephense = { - environment = { - phpVersion = '8.2.0' - } - } - } -} -nvim_lsp['clangd'].setup { - on_attach = default_on_attach, - capabilities = capabilities -} -require("flutter-tools").setup { - outline = { - open_cmd = "Vista" - }, - lsp = { - on_attach = default_on_attach, - capabilities = capabilities - } -} -nvim_lsp['twiggy_language_server'].setup { - on_attach = default_on_attach, - capabilities = capabilities, - settings = { - twiggy = { - framework = 'symfony', - phpExecutable = '/usr/bin/php', - symfonyConsolePath = 'bin/console', - diagnostics = { - twigCsFixer = false - } - } - } -} -vim.g.vim_vue_plugin_config = { - syntax = { - template = {'html'}, - script = {'javascript'}, - style = {'css'}, - }, - full_syntax = {}, - initial_indent = {}, - attribute = 0, - keyword = 0, - foldexpr = 0, - debug = 0 -} - -- -- Telescope -- @@ -280,12 +97,6 @@ vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', { noremap = true }) vim.api.nvim_set_keymap('n', 'r', ':NvimTreeRefresh', { noremap = true }) vim.api.nvim_set_keymap('n', 'n', ':NvimTreeFindFile', { noremap = true }) --- --- Theme --- -vim.cmd('colorscheme duskfox') -vim.opt.termguicolors = true - -- -- Lualine -- @@ -371,4 +182,16 @@ dap.configurations.cpp = { -- vim.g.vdebug_options = { port = '9000' } -EOF +-- +-- Treesitter +-- +require'nvim-treesitter.configs'.setup { + ensure_installed = { 'haskell', 'php', 'lua' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false + }, + indent = { + enable = true + } +}