~keving/dotfiles

a1df1d3f85ad9a5606f0df15b3f9fdbd7265f000 — Kevin Guillaumond 11 months ago 19ef738
Add Treesitter, LSP experiments
M .config/nvim/ftplugin/python.vim => .config/nvim/ftplugin/python.vim +5 -0
@@ 15,3 15,8 @@ if has('nvim')
    %s/Exception, e:/Exception as e:/g
  endfunction
endif

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

M .config/nvim/init.lua => .config/nvim/init.lua +23 -1
@@ 44,11 44,15 @@ paq 'lewis6991/gitsigns.nvim'  -- Shows git diff in the 'gutter' (sign column)
paq 'neovim/nvim-lspconfig'    -- Code navigation
paq 'hrsh7th/nvim-compe'       -- Code completion
paq 'knsh14/vim-github-link'   -- Generate shareable file permalinks
paq{'nvim-treesitter/nvim-treesitter', run=':TSUpdate'} -- Parser generator (highlighting etc)

-- Python
paq 'numirias/semshi'          -- Syntax highlighting
paq 'nvie/vim-flake8'          -- Python style checker

-- PlantUML
paq 'aklt/plantuml-syntax'     -- Syntax highlighting

-- Load plugin-specific configs
require 'plugin_configs/nvim-lspconfig'
require 'plugin_configs/nvim-compe_config'  -- TODO figure out why just 'nvim-compe' doesn't work


@@ 63,7 67,7 @@ require('gitsigns').setup()
utils.map('n', '<leader>ne', ':NERDTreeToggle<Enter>')

-- Ignore some files
cmd [[ let NERDTreeIgnore=['\.pyc$', '\~$'] ]]
cmd [[ let NERDTreeIgnore=['\.pyc$', '\~$', '\.o', '\.lo'] ]]

-- Automatically close NERDTree when you open a file
g['NERDTreeQuitOnOpen'] = 1


@@ 95,6 99,9 @@ cmd 'let g:syntastic_python_pylint_quiet_messages = { "level" : [] }'
-- to run pylint and flake8 asynchronously.
utils.map('n', '<leader>l', ':SyntasticCheck<CR>', {silent = true})

-- Disable Syntastic for c files - reply on LSP instead
cmd 'let g:syntastic_ignore_files = [".c"]'


-- Telescope
-- Shortcut for 'go to buffer'


@@ 102,6 109,21 @@ utils.map('n', 'gb', ':Telescope buffers<CR>')
utils.map('n', '<leader>ff', ':Telescope find_files<CR>')


-- Treesitter
require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
  },
  indent = {
    enable = false,
  },
  ensure_installed = {
    "c",
	"cpp",
  },
}


-- vim-test
-- Run tests in a split window
cmd "let g:test#strategy = 'neovim'"

M .config/nvim/lua/plugin_configs/nvim-lspconfig.lua => .config/nvim/lua/plugin_configs/nvim-lspconfig.lua +30 -6
@@ 3,15 3,39 @@ local cmd = vim.cmd
local utils = require('utils')

-- Set up language servers
require'lspconfig'.clangd.setup{}  -- C / C++
require'lspconfig'.pyright.setup{}  -- Python
require'lspconfig'.clangd.setup{
  -- on_attach = keybinds.on_attach,
  cmd = {
    'clangd',
    '--background-index',
    '--suggest-missing-includes',
    -- '--query-driver="/usr/local/opt/gcc-arm-none-eabi-8-2019-q3-update/bin/arm-none-eabi-gcc"'
  },
  filetypes = {'c'},
}
require'lspconfig'.ccls.setup{
  filetypes = {'cpp'},
}
require'lspconfig'.pyright.setup{
  filetypes = {'python'},
}


utils.map('n', '<leader>rr', '<cmd>lua vim.lsp.buf.rename()<CR>', {silent = true})
utils.map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', {silent = true})
utils.map('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', {silent = true})
utils.map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', {silent = true}) -- TODO still try vim docs first
local opts = { noremap=true, silent=true }

utils.map('n', '<leader>rr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
utils.map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
utils.map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
utils.map('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
utils.map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
if vim.fn.has 'nvim-0.6' == 1 then
	utils.map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
	utils.map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
else
	utils.map('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
	utils.map('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
end
utils.map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) -- TODO still try vim docs first

-- TODO Map K to this so it shows vim documentation first
-- vim.api.nvim_exec([[