changeset 280:dd8b9d0c0e41

Move lua config to lua.init
author zegervdv <zegervdv@me.com>
date Tue, 25 Aug 2020 09:35:59 +0200
parents 994e456b145e
children dfd62b5a9962
files dot_config/nvim/init.lua dot_config/nvim/init.vim dot_config/nvim/lua/on_attach.lua
diffstat 3 files changed, 79 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/nvim/init.lua	Tue Aug 25 09:35:59 2020 +0200
@@ -0,0 +1,77 @@
+local lsp = require'nvim_lsp'
+
+require "nvim-treesitter.highlight"
+-- local hlmap = vim.treesitter.TSHighlighter.hl_map
+
+require'nvim-treesitter.configs'.setup {
+  highlight = {
+    enable = true,
+  },
+  incremental_selection = {
+    enable = true,
+    keymaps = {
+      init_selection = "gnn",
+      node_incremental = "grn",
+      scope_incremental = "grc",
+      node_decremental = "grm",
+    }
+  },
+  refactor = {
+    smart_rename = {
+      enable = true,
+      keymaps = {
+        smart_rename = "grr",
+      },
+    },
+    navigation = {
+      enable = true,
+      keymaps = {
+        goto_definition = "gnd",
+        list_definitions = "gnD",
+      },
+    },
+  },
+}
+
+local chain_complete_list = {
+  default = {
+    default = {
+      {complete_items = {'lsp', 'snippet'}},
+      {complete_items = {'path'}, triggered_only = {'/'}},
+    },
+    string = {
+      {complete_items = {'path'}, triggered_only = {'/'}},
+    },
+    comment = {},
+  }
+}
+
+local on_attach = function(client)
+  require'diagnostic'.on_attach({
+    -- enable_virtual_text = 1,
+    -- virtual_text_prefix = 'F',
+  })
+  require'completion'.on_attach({
+    sorting = 'alphabet',
+    matching_strategy_list = {'exact', 'fuzzy'},
+    chain_complete_list = chain_complete_list,
+  })
+  -- This came from https://github.com/tjdevries/config_manager/blob/master/xdg_config/nvim/lua/lsp_config.lua
+  local mapper = function(mode, key, result)
+    vim.fn.nvim_buf_set_keymap(0, mode, key, result, {noremap=true, silent=true})
+  end
+
+  mapper('n', 'gd', '<cmd>lua vim.lsp.buf.declaration()<CR>')
+  mapper('n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<CR>')
+  mapper('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>')
+  mapper('n', 'gD', '<cmd>lua vim.lsp.buf.implementation()<CR>')
+  mapper('n', '1gD', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
+  mapper('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>')
+  mapper('n', 'g0', '<cmd>lua vim.lsp.buf.document_symbol()<CR>')
+  mapper('i', '<c-l>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
+end
+
+lsp.pyls.setup{
+    cmd = {"pyls"},
+    on_attach = on_attach;
+}
--- a/dot_config/nvim/init.vim	Tue Aug 25 08:56:35 2020 +0200
+++ b/dot_config/nvim/init.vim	Tue Aug 25 09:35:59 2020 +0200
@@ -1145,15 +1145,6 @@
   autocmd FileType python setlocal path-=**
   autocmd Filetype python let b:delimitMate_nesting_quotes = ['"', "'"]
 augroup END
-lua << EOF
-  vim.lsp.set_log_level("debug")
-EOF
-lua << EOF
-require'nvim_lsp'.pyls.setup{
-    cmd = {"pyls"},
-    on_attach = require'on_attach'.on_attach
-}
-EOF
 
 let g:python_highlight_all=1
 " }}}
@@ -1283,37 +1274,6 @@
 "   autocmd BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry
 " augroup END
 " }}}
-lua <<EOF
-require'nvim-treesitter.configs'.setup {
-  highlight = {
-    enable = true,
-  },
-  incremental_selection = {
-    enable = true,
-    keymaps = {
-      init_selection = "gnn",
-      node_incremental = "grn",
-      scope_incremental = "grc",
-      node_decremental = "grm",
-    }
-  },
-  refactor = {
-    smart_rename = {
-      enable = true,
-      keymaps = {
-        smart_rename = "grr",
-      },
-    },
-    navigation = {
-      enable = true,
-      keymaps = {
-        goto_definition = "gnd",
-        list_definitions = "gnD",
-      },
-    },
-  },
-}
-EOF
 " }}}
 
 function! SendOSCClipboard(lines, regtype)
@@ -1333,6 +1293,8 @@
       \   'cache_enabled': 1,
       \ }
 
+luafile ~/.config/nvim/init.lua
+
 " Load local vimrc
 if filereadable($HOME . '/.vimrc.local')
   source ~/.vimrc.local
--- a/dot_config/nvim/lua/on_attach.lua	Tue Aug 25 08:56:35 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-local M = {}
-
-M.on_attach = function()
-   require'diagnostic'.on_attach()
-   require'completion'.on_attach()
-end
-
-return M