]> src.twobees.de Git - dotfiles.git/blobdiff - stow/nvim/.config/nvim/init.lua
up
[dotfiles.git] / stow / nvim / .config / nvim / init.lua
index 4e56abb6657d4b02d1189d273de2760b828d0243..c4922ec27b5c8b157293f8e407ec2cf205f189ff 100644 (file)
@@ -20,6 +20,11 @@ vim.opt.rtp:prepend(lazypath)
 require('lazy').setup({
   -- NOTE: First, some plugins that don't require any configuration
 
+  'jose-elias-alvarez/null-ls.nvim',
+  'MunifTanjim/prettier.nvim',
+
+  '907th/vim-auto-save',
+
   -- Git related plugins
   'tpope/vim-fugitive',
   'tpope/vim-rhubarb',
@@ -27,6 +32,7 @@ require('lazy').setup({
   -- Detect tabstop and shiftwidth automatically
   'tpope/vim-sleuth',
 
+
   -- NOTE: This is where your plugins related to LSP can be installed.
   --  The configuration is done below. Search for lspconfig to find it below.
   {
@@ -39,7 +45,7 @@ require('lazy').setup({
 
       -- Useful status updates for LSP
       -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
-      { 'j-hui/fidget.nvim',       opts = {} },
+      { 'j-hui/fidget.nvim',       opts = {},    tag = 'legacy' },
 
       -- Additional lua configuration, makes nvim stuff amazing!
       'folke/neodev.nvim',
@@ -49,8 +55,12 @@ require('lazy').setup({
   {
     -- Autocompletion
     'hrsh7th/nvim-cmp',
-    dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip',
-      'rafamadriz/friendly-snippets' },
+    dependencies = {
+      'hrsh7th/cmp-nvim-lsp',
+      { 'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp" },
+      'saadparwaiz1/cmp_luasnip',
+      'rafamadriz/friendly-snippets'
+    },
   },
 
   -- Useful plugin to show you pending keybinds.
@@ -90,16 +100,8 @@ require('lazy').setup({
     },
   },
 
-  {
-    -- Add indentation guides even on blank lines
-    'lukas-reineke/indent-blankline.nvim',
-    -- Enable `lukas-reineke/indent-blankline.nvim`
-    -- See `:help indent_blankline.txt`
-    opts = {
-      char = '┊',
-      show_trailing_blankline_indent = false,
-    },
-  },
+  -- {  dir = '~/github/mynvimplugins/btoggle.nvim/' },
+  {  'tobser/btoggle.nvim' },
 
   -- "gc" to comment visual regions/lines
   { 'numToStr/Comment.nvim',         opts = {} },
@@ -132,7 +134,7 @@ require('lazy').setup({
   -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
   --       These are some example plugins that I've included in the kickstart repository.
   --       Uncomment any of the lines below to enable them.
-  require 'autoformat',
+  -- require 'autoformat',
   -- require 'kickstart.plugins.debug',
 
   -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
@@ -150,10 +152,11 @@ require('lazy').setup({
 -- See `:help vim.o`
 
 -- Set highlight on search
-vim.o.hlsearch = false
+vim.o.hlsearch = true
 
 -- Make line numbers default
 vim.wo.relativenumber = true
+vim.wo.number = true
 
 -- Enable mouse mode
 vim.o.mouse = 'a'
@@ -265,13 +268,13 @@ augroup END
 require('nvim-treesitter.configs').setup {
   -- Add languages to be installed here that you want installed for treesitter
   ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim', 'html',
-    'c_sharp', 'perl' },
+    'c_sharp', 'perl', 'bash', 'python' ,'markdown' },
 
   -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
   auto_install = false,
 
   highlight = { enable = true },
-  indent = { enable = true, disable = { 'python' } },
+  indent = { enable = false, disable = { 'python' } },
   incremental_selection = {
     enable = true,
     keymaps = {
@@ -326,16 +329,20 @@ require('nvim-treesitter.configs').setup {
     },
   },
 }
-
 -- 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', '<S-F8>', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
+vim.keymap.set('n', '<F8>', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
 vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
 vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
 
+vim.keymap.set("n", "<Leader>f", function()
+  vim.lsp.buf.format({ timeout = 10000, bufnr = vim.api.nvim_get_current_buf() })
+end)
 -- LSP settings.
 --  This function gets run when an LSP connects to a particular buffer.
-local on_attach = function(_, bufnr)
+local on_attach = function(client, bufnr)
   -- NOTE: Remember that lua is a real programming language, and as such it is possible
   -- to define small helper and utility functions so you don't have to repeat yourself
   -- many times.
@@ -343,9 +350,10 @@ local on_attach = function(_, bufnr)
   local nmap = function(keys, func, desc)
     if desc then
       desc = 'LSP: ' .. desc
+      vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
+    else
+      vim.keymap.set('n', keys, func, { buffer = bufnr })
     end
-
-    vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
   end
 
   nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
@@ -387,6 +395,8 @@ local servers = {
   -- pyright = {},
   -- rust_analyzer = {},
   tsserver = {},
+  eslint = {},
+  tailwindcss = {},
   lua_ls = {
     Lua = {
       workspace = { checkThirdParty = false },
@@ -419,6 +429,38 @@ mason_lspconfig.setup_handlers {
   end,
 }
 
+-- require('lspconfig').perlls.setup {
+--   settings = {
+--     perl = {
+--       perlInc = {
+--         '/home/pi/git/misterhouse/lib',
+--         '/home/pi/git/misterhouse/bin',
+--       },
+--     },
+--   },
+--   capabilities = capabilities,
+--   on_attach = on_attach,
+-- }
+--
+require('lspconfig').perlpls.setup {
+  on_attach = on_attach,
+  settings = {
+    perl = {
+      perlcritic = {
+        enabled = false
+      },
+      syntax = {
+        enabled = true
+      },
+      inc = {
+        '/home/pi/git/misterhouse/lib',
+        '/home/pi/git/misterhouse/bin',
+      },
+    },
+  },
+  capabilities = capabilities,
+}
+
 -- nvim-cmp setup
 local cmp = require 'cmp'
 local luasnip = require 'luasnip'
@@ -466,5 +508,55 @@ cmp.setup {
   },
 }
 
+
+local null_ls = require("null-ls")
+
+local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false })
+local event = "BufWritePre" -- or "BufWritePost"
+local async = event == "BufWritePost"
+
+null_ls.setup({
+  timeout = 2000,
+  on_attach = on_attach
+})
+
+
+local prettier = require("prettier")
+
+prettier.setup({
+  bin = 'prettierd', -- or `'prettierd'` (v0.23.3+)
+  filetypes = {
+    "css",
+    "graphql",
+    "html",
+    "javascript",
+    "javascriptreact",
+    "json",
+    "less",
+    "perl",
+    "markdown",
+    "scss",
+    "typescript",
+    "typescriptreact",
+    "yaml",
+  },
+})
+
+vim.opt.diffopt = vim.opt.diffopt + "vertical"
+vim.opt.cursorline = true
+vim.opt.hlsearch = true
+
+local bt =  require("btoggle");
+bt.setup({
+  ["true"] = "false",
+  ["True"] = "False",
+  ["False"] = "True",
+  ["false"] = "true",
+  ["foo"] = "bar",
+  ["bar"] = "bor",
+  ["bor"] = "foo"
+})
+vim.keymap.set('n', '<leader>b', bt.toggle)
+
 -- The line beneath this is called `modeline`. See `:help modeline`
 -- vim: ts=2 sts=2 sw=2 et