diff options
Diffstat (limited to 'Common/nvim/lua')
-rwxr-xr-x | Common/nvim/lua/basic.lua | 9 | ||||
-rwxr-xr-x | Common/nvim/lua/helper_functions.lua | 11 | ||||
-rw-r--r-- | Common/nvim/lua/lsp-conf.lua | 156 | ||||
-rwxr-xr-x | Common/nvim/lua/plugins.lua | 81 |
4 files changed, 182 insertions, 75 deletions
diff --git a/Common/nvim/lua/basic.lua b/Common/nvim/lua/basic.lua index 7baa151..3749310 100755 --- a/Common/nvim/lua/basic.lua +++ b/Common/nvim/lua/basic.lua @@ -29,6 +29,9 @@ vim.api.nvim_create_user_command( {bang=true, desc='Save file using sudo'} ) +-- Disable the auto line wrap +vim.cmd [[ set formatoptions-=t ]] + --[[ VIM User interface --]] @@ -256,6 +259,12 @@ map('n', '<leader>sl', ':source vim_session.vim<cr>', silentnoremap) -- {bang = true} --) +--[[ +Debugging +--]] +vim.g.termdebug_popup = 0 +vim.g.termdebug_wide = 163 +vim.cmd([[:packadd termdebug]]) diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua index cd84fc9..515854f 100755 --- a/Common/nvim/lua/helper_functions.lua +++ b/Common/nvim/lua/helper_functions.lua @@ -66,6 +66,17 @@ end, {range = true, desc = 'Format JSON'}) vim.keymap.set('n', '<leader>jq', FormatJson, { noremap = true, silent = true }) vim.keymap.set('v', '<leader>jq', ':FormatJson<CR>', { noremap = true, silent = true }) +function English() + vim.opt.spell = true + vim.opt.spelllang = "en_us" +end +vim.api.nvim_create_user_command('English', English, {bang=false, desc='Enables spellchecking for english'}) +function Norsk() + vim.opt.spell = true + vim.opt.spelllang = "nb_no" +end +vim.api.nvim_create_user_command('Norsk', Norsk, {bang=false, desc='Enables spellchecking for norsk bokmål'}) + -- Close buffer without closing window --[[ vim.cmd [[ diff --git a/Common/nvim/lua/lsp-conf.lua b/Common/nvim/lua/lsp-conf.lua index 60fb1d2..18a8f12 100644 --- a/Common/nvim/lua/lsp-conf.lua +++ b/Common/nvim/lua/lsp-conf.lua @@ -1,34 +1,128 @@ --- lsp -require("mason").setup() -local lspconfig = require'lspconfig' -local coq = require "coq" - --- setup language servers here -local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, -} +-- Mason Setup +require("mason").setup({ + ui = { + icons = { + package_installed = "", + package_pending = "", + package_uninstalled = "", + }, + } +}) +require("mason-lspconfig").setup({ + ensure_installed = { "rust_analyzer", "tsserver", "clangd", "intelephense", "pyright", "ltex", "jdtls" } +}) +require("mason-lspconfig").setup_handlers { + function (server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, -local lspconfig = require('lspconfig') -lspconfig['pyright'].setup{ - on_attach = on_attach, - flags = lsp_flags, -} -lspconfig.ccls.setup { - single_file_support = true; - init_options = { - compilationDatabaseDirectory = "build"; - index = { - threads = 0; - }; - clang = { - excludeArgs = { "-frounding-math"} ; - }; - } + ["rust_analyzer"] = function () + require("rust-tools").setup {} + end } -lspconfig.ccls.setup{} -lspconfig.intelephense.setup{} -lspconfig.cssls.setup{} -lspconfig.html.setup{} -lspconfig.bashls.setup{} +-- LSP Diagnostics Options Setup +local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({name = 'DiagnosticSignError', text = ''}) +sign({name = 'DiagnosticSignWarn', text = ''}) +sign({name = 'DiagnosticSignHint', text = ''}) +sign({name = 'DiagnosticSignInfo', text = ''}) + +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = true, + underline = true, + severity_sort = false, + float = { + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +}) + +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +-- Fixed column for diagnostics to appear +-- Show autodiagnostic popup on cursor hover_range +-- Goto previous / next diagnostic warning / error +-- Show inlay_hints more frequently +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +-- Completion Plugin Setup +local cmp = require'cmp' +cmp.setup({ + -- Enable LSP snippets + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-n>'] = cmp.mapping.select_next_item(), + -- Add tab support + ['<S-Tab>'] = cmp.mapping.select_prev_item(), + ['<Tab>'] = cmp.mapping.select_next_item(), + ['<C-S-f>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.close(), + ['<CR>'] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + -- Installed sources: + sources = { + { name = 'path' }, -- file paths + { name = 'nvim_lsp', keyword_length = 3 }, -- from language server + { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized + { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* + { name = 'buffer', keyword_length = 2 }, -- source current buffer + { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip + { name = 'calc'}, -- source for math calculation + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + vsnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua index c307129..d80bf28 100755 --- a/Common/nvim/lua/plugins.lua +++ b/Common/nvim/lua/plugins.lua @@ -113,55 +113,34 @@ return require('packer').startup(function(use) use { 'tpope/vim-surround' } -- Tree-sitter-mysql - use { 'PatrickFeiring/tree-sitter-sql' } + -- use { 'PatrickFeiring/tree-sitter-sql' } -- terryma/vim-multiple-cursors -- preservim/nerdcommenter -- Lsp things - use 'neovim/nvim-lsp' - use { - 'neovim/nvim-lspconfig', - config = function() - local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, - } - local lspconfig = require('lspconfig') - lspconfig['pyright'].setup{ - on_attach = on_attach, - flags = lsp_flags, - } - lspconfig.ccls.setup { - single_file_support = true; - init_options = { - compilationDatabaseDirectory = "build"; - index = { - threads = 0; - }; - clang = { - excludeArgs = { "-frounding-math"} ; - }; - } - } - - lspconfig.ccls.setup{} - lspconfig.intelephense.setup{} - lspconfig.cssls.setup{} - lspconfig.html.setup{} - lspconfig.bashls.setup{} - end, - } - --use 'kabouzeid/nvim-lspinstall' use { 'williamboman/mason.nvim', - config = function() - - end, + 'williamboman/mason-lspconfig.nvim', + 'neovim/nvim-lspconfig' , } use 'ms-jpq/coq_nvim' + -- Language-specifics + use 'simrat39/rust-tools.nvim' + --use 'mfussenegger/nvim-jdtls' + + -- Completion framework: + use 'hrsh7th/nvim-cmp' + -- LSP completion source: + use 'hrsh7th/cmp-nvim-lsp' + -- Useful completion sources: + use 'hrsh7th/cmp-nvim-lua' + use 'hrsh7th/cmp-nvim-lsp-signature-help' + use 'hrsh7th/cmp-vsnip' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-buffer ' + use 'hrsh7th/vim-vsnip' - use 'mfussenegger/nvim-jdtls' -- Goyo :) use { @@ -187,20 +166,31 @@ return require('packer').startup(function(use) config = function () vim.g.vimwiki_list = { { - path = '~/Nextcloud/wiki/P01/', + path = '~/Nextcloud/wiki/I45', syntax = 'markdown', ext = 'md', - --nested_syntaxes = { - -- python = 'python', - --}, + name = 'I45', + auto_toc = 1, + diary_frequency = 'daily', + nested_syntaxes = { + python = 'python', + sql = 'sql', + }, }, { - path = '~/Nextcloud/wiki/I45', + path = '~/Nextcloud/wiki/P01/', syntax = 'markdown', ext = 'md', + name = 'P01', + --nested_syntaxes = { + -- python = 'python', + --}, }, } vim.g.vimwiki_global_ext = 0 + vim.g.vimwiki_auto_header = 1 + vim.g.vimwiki_links_space_char = '_' + vim.g.vimwiki_url_maxsave = 0 end, } use { @@ -225,6 +215,9 @@ return require('packer').startup(function(use) } -- packer.nvim + use 'evanleck/vim-svelte' + use 'pangloss/vim-javascript' + -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins if packer_bootstrap then |