From 6c91dbbe6388c70971999b1e1e554ec879ed742e Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Sat, 23 Jul 2022 11:52:42 +0200 Subject: [PATCH] nvim: better lua conf --- .config/nvim/lua/dln/lsp-config.lua | 17 ++++----- .config/nvim/lua/plugins.lua | 19 +++++----- .config/nvim/lua/settings.lua | 57 ++++++++++++++--------------- 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/.config/nvim/lua/dln/lsp-config.lua b/.config/nvim/lua/dln/lsp-config.lua index 7c93950..e4e32ad 100644 --- a/.config/nvim/lua/dln/lsp-config.lua +++ b/.config/nvim/lua/dln/lsp-config.lua @@ -48,7 +48,10 @@ local efm_prettier = { lspconfig.sumneko_lua.setup { - cmd = {"lua-language-server", "-E", "/usr/share/lua-language-server/main.lua"}, + on_attach = function() + on_attach() + vim.cmd([[autocmd BufWritePre lua require'stylua-nvim'.format_file()]]) + end, settings = { Lua = { completion = {kewordSnippet = "Disable"}, @@ -61,14 +64,10 @@ lspconfig.sumneko_lua.setup { path = {"?.lua", "?/init.lua", "?/?.lua"} }, workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - [vim.fn.stdpath("data") .. "/site/pack"] = true - }, - maxPreload = 2000, - preloadFileSize = 1000 + library = vim.api.nvim_get_runtime_file("", true), + maxPreload = 2000, + preloadFileSize = 1000, + checkThirdParty = false, } } } diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index c318f67..5b0d4ee 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -9,6 +9,7 @@ return require('packer').startup(function() use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } use {'ray-x/guihua.lua', run = 'cd lua/fzy && make'} use 'jjo/vim-cue' + use("ckipp01/stylua-nvim") use { 'theHamsta/nvim-dap-virtual-text', @@ -216,15 +217,6 @@ return require('packer').startup(function() config = function() require("plugins/nvim-dap-go") end, } - -- zenbones - use { - "mcchrish/zenbones.nvim", - requires = { - "rktjmp/lush.nvim", - }, - config = function() require("plugins/zenbones") end, - } - -- lsp_lines use { "https://git.sr.ht/~whynothugo/lsp_lines.nvim", @@ -236,6 +228,15 @@ return require('packer').startup(function() end } + -- zenbones + use { + "mcchrish/zenbones.nvim", + requires = { + "rktjmp/lush.nvim", + }, + config = function() require("plugins/zenbones") end, + } + -- copilot -- use({ -- "github/copilot.vim", diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index d28e919..11394bb 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -1,9 +1,9 @@ -vim.cmd[[set undofile]] -vim.cmd[[set completeopt-=preview]] -vim.cmd[[set viewoptions-=options]] -vim.g.mapleader = ',' +vim.cmd([[set undofile]]) +vim.cmd([[set completeopt-=preview]]) +vim.cmd([[set viewoptions-=options]]) +vim.g.mapleader = "," vim.o.hidden = true -vim.o.mouse = 'a' +vim.o.mouse = "a" vim.o.splitbelow = true vim.o.splitright = true vim.o.ttimeout = true @@ -21,7 +21,7 @@ vim.o.breakindent = true vim.o.expandtab = true vim.o.smartindent = true vim.o.joinspaces = false -vim.o.listchars = 'extends:›,precedes:‹,nbsp:·,tab:→ ,trail:·' +vim.o.listchars = "extends:›,precedes:‹,nbsp:·,tab:→ ,trail:·" vim.wo.foldlevel = 99 vim.wo.linebreak = true vim.wo.list = true @@ -30,22 +30,22 @@ vim.o.tabstop = 2 vim.o.softtabstop = 2 --- Search -vim.cmd('set path+=**') -vim.cmd('set wildignore+=*/tmp/*,/var/*,*.so,*.swp,*.zip,*.tar,*.pyc') +vim.cmd("set path+=**") +vim.cmd("set wildignore+=*/tmp/*,/var/*,*.so,*.swp,*.zip,*.tar,*.pyc") vim.o.ignorecase = true vim.o.smartcase = true -vim.o.wildmode = 'longest:full,full' +vim.o.wildmode = "longest:full,full" -if vim.fn.executable('rg') then - vim.o.grepprg = 'rg --vimgrep --no-heading --smart-case' +if vim.fn.executable("rg") then + vim.o.grepprg = "rg --vimgrep --no-heading --smart-case" end --- Completion -vim.cmd('set shortmess+=c') -vim.o.completeopt = 'menuone,noinsert,noselect' +vim.cmd("set shortmess+=c") +vim.o.completeopt = "menuone,noinsert,noselect" --- Appearance -vim.o.background = 'light' +vim.o.background = "light" vim.o.scrolloff = 5 vim.o.showmode = false vim.o.sidescrolloff = 5 @@ -63,27 +63,26 @@ vim.wo.foldexpr = "nvim_treesitter#foldexpr()" --- Key mappings local map = require("dln.utils").map -map('n', '', ':let @/=""') -- clear search -map('n', 'H', '^') -map('n', 'L', '$') -map('i', '', '') +map("n", "", ':let @/=""') -- clear search +map("n", "H", "^") +map("n", "L", "$") +map("i", "", "") -map('n', ',L', ':luafile %') -- Reload lua file +map("n", ",L", ":luafile %") -- Reload lua file --- Plugins vim.g.netrw_dirhistmax = 0 - local border = { - {"🭽", "FloatBorder"}, - {"▔", "FloatBorder"}, - {"🭾", "FloatBorder"}, - {"▕", "FloatBorder"}, - {"🭿", "FloatBorder"}, - {"▁", "FloatBorder"}, - {"🭼", "FloatBorder"}, - {"▏", "FloatBorder"}, + { "🭽", "FloatBorder" }, + { "▔", "FloatBorder" }, + { "🭾", "FloatBorder" }, + { "▕", "FloatBorder" }, + { "🭿", "FloatBorder" }, + { "▁", "FloatBorder" }, + { "🭼", "FloatBorder" }, + { "▏", "FloatBorder" }, } vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border }) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border })