X-Git-Url: https://src.twobees.de/?a=blobdiff_plain;f=stow%2Fnvim%2F.config%2Fnvim%2Finit.lua;h=c4922ec27b5c8b157293f8e407ec2cf205f189ff;hb=refs%2Fheads%2Fmain;hp=bfc6ee34b7bab9d1b1449d77cae9b1ed8bed8068;hpb=62c3c3dc07cdcd09f1712f6eb4eb658c8be6bf01;p=dotfiles.git diff --git a/stow/nvim/.config/nvim/init.lua b/stow/nvim/.config/nvim/init.lua index bfc6ee3..c4922ec 100644 --- a/stow/nvim/.config/nvim/init.lua +++ b/stow/nvim/.config/nvim/init.lua @@ -32,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. { @@ -56,7 +57,7 @@ require('lazy').setup({ 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', - {'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp"}, + { 'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp" }, 'saadparwaiz1/cmp_luasnip', 'rafamadriz/friendly-snippets' }, @@ -99,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 = {} }, @@ -159,7 +152,7 @@ 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 @@ -275,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', 'python' }, + '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 = { @@ -336,7 +329,6 @@ 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' }) @@ -344,9 +336,13 @@ vim.keymap.set('n', '', vim.diagnostic.goto_prev, { desc = 'Go to previous vim.keymap.set('n', '', 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' }) + +vim.keymap.set("n", "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. @@ -354,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('rn', vim.lsp.buf.rename, '[R]e[n]ame') @@ -398,6 +395,8 @@ local servers = { -- pyright = {}, -- rust_analyzer = {}, tsserver = {}, + eslint = {}, + tailwindcss = {}, lua_ls = { Lua = { workspace = { checkThirdParty = false }, @@ -430,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' @@ -478,9 +509,6 @@ cmp.setup { } - - - local null_ls = require("null-ls") local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false }) @@ -488,30 +516,8 @@ local event = "BufWritePre" -- or "BufWritePost" local async = event == "BufWritePost" null_ls.setup({ - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.keymap.set("n", "f", function() - vim.lsp.buf.format({ timeout = 10000, bufnr = vim.api.nvim_get_current_buf() }) - end, { buffer = bufnr, desc = "[lsp] format" }) - - -- -- format on save - -- vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group }) - -- vim.api.nvim_create_autocmd(event, { - -- buffer = bufnr, - -- group = group, - -- callback = function() - -- vim.lsp.buf.format({ bufnr = bufnr, async = async }) - -- end, - -- desc = "[lsp] format on save", - -- }) - end - - if client.supports_method("textDocument/rangeFormatting") then - vim.keymap.set("x", "f", function() - vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() }) - end, { buffer = bufnr, desc = "[lsp] format" }) - end - end, + timeout = 2000, + on_attach = on_attach }) @@ -527,6 +533,7 @@ prettier.setup({ "javascriptreact", "json", "less", + "perl", "markdown", "scss", "typescript", @@ -536,6 +543,20 @@ prettier.setup({ }) 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', 'b', bt.toggle) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et