reworked nvim config files
This commit is contained in:
parent
038a0d6940
commit
b76ed824de
6 changed files with 202 additions and 203 deletions
|
@ -1,207 +1,31 @@
|
||||||
--vim.opt.termguicolors = true
|
----------------------
|
||||||
-- plugins
|
-- general settings --
|
||||||
require "paq" {
|
----------------------
|
||||||
"savq/paq-nvim"; -- Let Paq manage itself
|
|
||||||
"nvim-lualine/lualine.nvim";
|
|
||||||
{ 'kyazdani42/nvim-web-devicons', opt=true };
|
|
||||||
|
|
||||||
'neovim/nvim-lspconfig'; -- Collection of configurations for built-in LSP client
|
|
||||||
'hrsh7th/nvim-cmp'; -- Autocompletion plugin
|
|
||||||
'hrsh7th/cmp-nvim-lsp'; -- LSP source for nvim-cmp
|
|
||||||
'saadparwaiz1/cmp_luasnip'; -- Snippets source for nvim-cmp
|
|
||||||
'L3MON4D3/LuaSnip'; -- Snippets plugin
|
|
||||||
|
|
||||||
'nvim-treesitter/nvim-treesitter';
|
|
||||||
|
|
||||||
'windwp/nvim-autopairs';
|
|
||||||
'tpope/vim-surround';
|
|
||||||
'dhruvasagar/vim-table-mode';
|
|
||||||
|
|
||||||
'ap/vim-css-color';
|
|
||||||
'elkowar/yuck.vim';
|
|
||||||
}
|
|
||||||
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
|
||||||
-- A list of parser names, or "all"
|
|
||||||
ensure_installed = { "lua", "python" },
|
|
||||||
|
|
||||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
|
||||||
sync_install = false,
|
|
||||||
|
|
||||||
-- List of parsers to ignore installing (for "all")
|
|
||||||
--ignore_install = { "javascript" },
|
|
||||||
|
|
||||||
highlight = {
|
|
||||||
-- `false` will disable the whole extension
|
|
||||||
enable = true,
|
|
||||||
|
|
||||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
|
||||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
|
||||||
-- the name of the parser)
|
|
||||||
-- list of language that will be disabled
|
|
||||||
--disable = { "c", "rust" },
|
|
||||||
|
|
||||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
|
||||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
|
||||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
|
||||||
-- Instead of true it can also be a list of languages
|
|
||||||
additional_vim_regex_highlighting = false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
require'lualine'.setup {
|
|
||||||
options = {
|
|
||||||
icons_enabled = true,
|
|
||||||
theme = 'auto',
|
|
||||||
component_separators = { left = '', right = ''},
|
|
||||||
section_separators = { left = '', right = ''},
|
|
||||||
disabled_filetypes = {},
|
|
||||||
always_divide_middle = true,
|
|
||||||
},
|
|
||||||
sections = {
|
|
||||||
lualine_a = {'mode'},
|
|
||||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
|
||||||
lualine_c = {'filename'},
|
|
||||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
|
||||||
lualine_y = {'progress'},
|
|
||||||
lualine_z = {'location'}
|
|
||||||
},
|
|
||||||
inactive_sections = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = {'filename'},
|
|
||||||
lualine_x = {'location'},
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {}
|
|
||||||
},
|
|
||||||
tabline = {},
|
|
||||||
extensions = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- require'lspconfig'.pylsp.setup{}
|
|
||||||
|
|
||||||
-- Add additional capabilities supported by nvim-cmp
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
||||||
|
|
||||||
local lspconfig = require('lspconfig')
|
|
||||||
|
|
||||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
|
||||||
local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'tsserver' }
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
lspconfig[lsp].setup {
|
|
||||||
-- on_attach = my_custom_on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- luasnip setup
|
|
||||||
local luasnip = require 'luasnip'
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = {
|
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
||||||
['<C-d>'] = 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.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
['<Tab>'] = function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
['<S-Tab>'] = function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
require('nvim-autopairs').setup{}
|
|
||||||
-- If you want insert `(` after select function or method item
|
|
||||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
|
||||||
local cmp = require('cmp')
|
|
||||||
cmp.event:on(
|
|
||||||
'confirm_done',
|
|
||||||
cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })
|
|
||||||
)
|
|
||||||
|
|
||||||
-- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" }
|
|
||||||
--cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket"
|
|
||||||
|
|
||||||
vim.cmd [[
|
|
||||||
function! s:isAtStartOfLine(mapping)
|
|
||||||
let text_before_cursor = getline('.')[0 : col('.')-1]
|
|
||||||
let mapping_pattern = '\V' . escape(a:mapping, '\')
|
|
||||||
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
|
|
||||||
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
inoreabbrev <expr> <bar><bar>
|
|
||||||
\ <SID>isAtStartOfLine('\|\|') ?
|
|
||||||
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
|
|
||||||
inoreabbrev <expr> __
|
|
||||||
\ <SID>isAtStartOfLine('__') ?
|
|
||||||
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
|
|
||||||
]]
|
|
||||||
|
|
||||||
---
|
|
||||||
local set = vim.opt
|
local set = vim.opt
|
||||||
|
|
||||||
--vim.g.markdown_fenced_languages = ['css', 'html', 'python', 'bash=sh']
|
set.wrap = true
|
||||||
set.wrap = true
|
set.linebreak = true
|
||||||
set.linebreak = true
|
set.breakindent = true
|
||||||
set.breakindent = true
|
set.breakindentopt = {'shift:2', 'sbr'}
|
||||||
set.breakindentopt = {'shift:2', 'sbr'}
|
set.showbreak = ' >'
|
||||||
set.showbreak = ' >'
|
|
||||||
|
|
||||||
set.number = true
|
set.number = true
|
||||||
set.relativenumber = true
|
set.relativenumber = true
|
||||||
set.encoding = "utf-8"
|
set.encoding = "utf-8"
|
||||||
|
|
||||||
--set.filetype = true
|
|
||||||
--set.filetype.plugin = true
|
|
||||||
--set.filetype.indent = true
|
|
||||||
|
|
||||||
-- search
|
-- search
|
||||||
set.hlsearch = true
|
set.hlsearch = true
|
||||||
set.ignorecase = true
|
set.ignorecase = true
|
||||||
set.smartcase = true
|
set.smartcase = true
|
||||||
|
|
||||||
-- indentation
|
-- indentation
|
||||||
set.smarttab = true
|
set.smarttab = true
|
||||||
set.expandtab = false
|
set.expandtab = false
|
||||||
set.copyindent = true
|
set.copyindent = true
|
||||||
set.preserveindent = true
|
set.preserveindent = true
|
||||||
set.tabstop = 4
|
set.tabstop = 4
|
||||||
set.shiftwidth = 4
|
set.shiftwidth = 4
|
||||||
set.softtabstop = 0
|
set.softtabstop = 0
|
||||||
|
|
||||||
local group = vim.api.nvim_create_augroup("WrapMarkdown", { clear = true })
|
local group = vim.api.nvim_create_augroup("WrapMarkdown", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
@ -217,10 +41,14 @@ vim.cmd [[
|
||||||
let g:vim_markdown_folding_disabled=1
|
let g:vim_markdown_folding_disabled=1
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- mapping
|
-- removes the background color to have it transparent
|
||||||
local map = vim.api.nvim_set_keymap
|
vim.api.nvim_create_autocmd({"ColorScheme"}, {
|
||||||
|
pattern = {"*"},
|
||||||
|
command = "hi Normal ctermbg=none guibg=none",
|
||||||
|
})
|
||||||
|
vim.cmd("colorscheme kanagawa")
|
||||||
|
|
||||||
|
require('plugins')
|
||||||
|
--require('core.colors')
|
||||||
|
require('core.mappings')
|
||||||
|
|
||||||
map('n', '<Space>', '', {})
|
|
||||||
map('n', '<Leader>n', ':bNext<CR>', {})
|
|
||||||
vim.g.mapleader = ' '
|
|
||||||
---
|
|
||||||
|
|
10
.config/nvim/lua/core/mappings.lua
Normal file
10
.config/nvim/lua/core/mappings.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
--------------
|
||||||
|
-- mappings --
|
||||||
|
--------------
|
||||||
|
local map = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
|
vim.g.mapleader = ' '
|
||||||
|
map('n', '<Space>', '', {})
|
||||||
|
map('n', '<Leader>n', '<cmd>:bNext<CR>', {})
|
||||||
|
map('n', '<Leader>p', '<cmd>:bprevious<CR>', {})
|
||||||
|
map('n', '<Leader>h', '<cmd>:nohlsearch<CR>', {})
|
51
.config/nvim/lua/plugins/init.lua
Normal file
51
.config/nvim/lua/plugins/init.lua
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
-------------
|
||||||
|
-- plugins --
|
||||||
|
-------------
|
||||||
|
require "paq" {
|
||||||
|
"savq/paq-nvim"; -- Let Paq manage itself
|
||||||
|
"nvim-lualine/lualine.nvim";
|
||||||
|
{ 'kyazdani42/nvim-web-devicons', opt=true };
|
||||||
|
|
||||||
|
'neovim/nvim-lspconfig'; -- Configs for Nvim LSP
|
||||||
|
'hrsh7th/nvim-cmp'; -- Autocompletion plugin
|
||||||
|
'hrsh7th/cmp-nvim-lsp'; -- LSP source for nvim-cmp
|
||||||
|
|
||||||
|
'L3MON4D3/LuaSnip'; -- Snippets plugin
|
||||||
|
'saadparwaiz1/cmp_luasnip'; -- Snippets source for nvim-cmp
|
||||||
|
|
||||||
|
'nvim-treesitter/nvim-treesitter'; -- Better syntax highlighting
|
||||||
|
|
||||||
|
'windwp/nvim-autopairs';
|
||||||
|
'tpope/vim-surround';
|
||||||
|
'dhruvasagar/vim-table-mode';
|
||||||
|
'lukas-reineke/indent-blankline.nvim';
|
||||||
|
|
||||||
|
'ap/vim-css-color';
|
||||||
|
'rebelot/kanagawa.nvim';
|
||||||
|
'folke/tokyonight.nvim';
|
||||||
|
--'elkowar/yuck.vim';
|
||||||
|
}
|
||||||
|
|
||||||
|
-- looks like tablemode for vim-table-mode in markdown
|
||||||
|
vim.cmd [[
|
||||||
|
function! s:isAtStartOfLine(mapping)
|
||||||
|
let text_before_cursor = getline('.')[0 : col('.')-1]
|
||||||
|
let mapping_pattern = '\V' . escape(a:mapping, '\')
|
||||||
|
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
|
||||||
|
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
inoreabbrev <expr> <bar><bar>
|
||||||
|
\ <SID>isAtStartOfLine('\|\|') ?
|
||||||
|
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
|
||||||
|
inoreabbrev <expr> __
|
||||||
|
\ <SID>isAtStartOfLine('__') ?
|
||||||
|
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
|
||||||
|
]]
|
||||||
|
|
||||||
|
require'plugins.lualine'
|
||||||
|
require'plugins.nvim-treesitter'
|
||||||
|
require'plugins.nvim-cmp'
|
||||||
|
require'indent_blankline'.setup{
|
||||||
|
show_current_context = true,
|
||||||
|
}
|
28
.config/nvim/lua/plugins/lualine.lua
Normal file
28
.config/nvim/lua/plugins/lualine.lua
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
require'lualine'.setup {
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = 'auto',
|
||||||
|
component_separators = { left = '', right = ''},
|
||||||
|
section_separators = { left = '', right = ''},
|
||||||
|
disabled_filetypes = {},
|
||||||
|
always_divide_middle = true,
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = {'mode'},
|
||||||
|
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||||
|
lualine_c = {'filename'},
|
||||||
|
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||||
|
lualine_y = {'progress'},
|
||||||
|
lualine_z = {'location'}
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = {'filename'},
|
||||||
|
lualine_x = {'location'},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {}
|
||||||
|
},
|
||||||
|
tabline = {},
|
||||||
|
extensions = {}
|
||||||
|
}
|
67
.config/nvim/lua/plugins/nvim-cmp.lua
Normal file
67
.config/nvim/lua/plugins/nvim-cmp.lua
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
local luasnip = require 'luasnip'
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-d>'] = 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.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require('nvim-autopairs').setup{}
|
||||||
|
cmp.event:on(
|
||||||
|
'confirm_done',
|
||||||
|
require('nvim-autopairs.completion.cmp').on_confirm_done({
|
||||||
|
map_char = { tex = '' }
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
-- require'lspconfig'.pylsp.setup{}
|
||||||
|
|
||||||
|
-- Add additional capabilities supported by nvim-cmp
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||||
|
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
|
||||||
|
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||||
|
local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'tsserver' }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
lspconfig[lsp].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
end
|
15
.config/nvim/lua/plugins/nvim-treesitter.lua
Normal file
15
.config/nvim/lua/plugins/nvim-treesitter.lua
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
-- A list of parser names, or "all"
|
||||||
|
ensure_installed = { "lua", "python" },
|
||||||
|
|
||||||
|
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||||
|
sync_install = false,
|
||||||
|
|
||||||
|
highlight = {
|
||||||
|
-- `false` will disable the whole extension
|
||||||
|
enable = true,
|
||||||
|
|
||||||
|
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in a new issue