From 7aae99d19f6f9b1f813deb743a7bda1e1bea8968 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 11 Mar 2023 10:15:33 +0900 Subject: [PATCH 01/28] update: nvim config: replace `\t` with space --- dotfiles/neovim/init.lua | 92 ++++++++++++++++----------------- dotfiles/neovim/lua/plugins.lua | 40 +++++++------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 29f6a90..6ed68de 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -28,16 +28,16 @@ vim.o.smartcase = true -- vim script func returns 1/0, while lua evals false only if gets false or nil -- so be sure to compare with 1/0 if vim.fn.has('win32') == 1 then - if vim.fn.executable('pwsh') == 1 then - vim.opt.shell = 'pwsh' - else - vim.opt.shell = 'powershell' - end - vim.opt.shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' - vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' - vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' - vim.opt.shellquote = '' - vim.opt.shellxquote = '' + if vim.fn.executable('pwsh') == 1 then + vim.opt.shell = 'pwsh' + else + vim.opt.shell = 'powershell' + end + vim.opt.shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' + vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' + vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + vim.opt.shellquote = '' + vim.opt.shellxquote = '' end @@ -52,18 +52,18 @@ vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] -- 1. LSP Sever management --require('mason').setup() --require('mason-lspconfig').setup_handlers({ function(server) --- local opt = { --- -- -- Function executed when the LSP server startup --- -- on_attach = function(client, bufnr) --- -- local opts = { noremap=true, silent=true } --- -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) --- -- vim.cmd 'autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)' --- -- end, --- capabilities = require('cmp_nvim_lsp').update_capabilities( --- vim.lsp.protocol.make_client_capabilities() --- ) --- } --- require('lspconfig')[server].setup(opt) +-- local opt = { +-- -- -- Function executed when the LSP server startup +-- -- on_attach = function(client, bufnr) +-- -- local opts = { noremap=true, silent=true } +-- -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) +-- -- vim.cmd 'autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)' +-- -- end, +-- capabilities = require('cmp_nvim_lsp').update_capabilities( +-- vim.lsp.protocol.make_client_capabilities() +-- ) +-- } +-- require('lspconfig')[server].setup(opt) --end }) -- ---- 2. build-in LSP function @@ -82,7 +82,7 @@ vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] --vim.keymap.set('n', 'g[', 'lua vim.diagnostic.goto_prev()') ---- LSP handlers --vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( --- vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false } +-- vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false } --) ---- Reference highlight --vim.cmd [[ @@ -100,26 +100,26 @@ vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] ---- 3. completion (hrsh7th/nvim-cmp) --local cmp = require("cmp") --cmp.setup({ --- snippet = { --- expand = function(args) --- vim.fn["vsnip#anonymous"](args.body) --- end, --- }, --- sources = { --- { name = "nvim_lsp" }, --- -- { name = "buffer" }, --- -- { name = "path" }, --- }, --- mapping = cmp.mapping.preset.insert({ --- [""] = cmp.mapping.select_prev_item(), --- [""] = cmp.mapping.select_next_item(), --- [''] = cmp.mapping.complete(), --- [''] = cmp.mapping.abort(), --- [""] = cmp.mapping.confirm { select = true }, --- }), --- experimental = { --- ghost_text = true, --- }, +-- snippet = { +-- expand = function(args) +-- vim.fn["vsnip#anonymous"](args.body) +-- end, +-- }, +-- sources = { +-- { name = "nvim_lsp" }, +-- -- { name = "buffer" }, +-- -- { name = "path" }, +-- }, +-- mapping = cmp.mapping.preset.insert({ +-- [""] = cmp.mapping.select_prev_item(), +-- [""] = cmp.mapping.select_next_item(), +-- [''] = cmp.mapping.complete(), +-- [''] = cmp.mapping.abort(), +-- [""] = cmp.mapping.confirm { select = true }, +-- }), +-- experimental = { +-- ghost_text = true, +-- }, --}) ---- cmp.setup.cmdline('/', { ---- mapping = cmp.mapping.preset.cmdline(), @@ -143,8 +143,8 @@ vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] ----------------------------------------------------------- -- Ctrl + P to invoke fzf file search vim.api.nvim_set_keymap('n', '', - "lua require('fzf-lua').files()", - { noremap = true, silent = true }) + "lua require('fzf-lua').files()", + { noremap = true, silent = true }) ----------------------------------------------------------- @@ -152,6 +152,6 @@ vim.api.nvim_set_keymap('n', '', require('lualine_setup') lualine = require('lualine') lualine.setup({ - options = { theme = 'iceberg_dark' } + options = { theme = 'iceberg_dark' } }) lualine.setup() diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua index 4ec117b..4f5a910 100644 --- a/dotfiles/neovim/lua/plugins.lua +++ b/dotfiles/neovim/lua/plugins.lua @@ -1,29 +1,29 @@ vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' + use 'wbthomason/packer.nvim' - -- fzf - use { 'ibhagwan/fzf-lua', - -- optional icon - --requires = { 'kyazdan142/nvim-web/devicons' } -- not found - } + -- fzf + use { 'ibhagwan/fzf-lua', + -- optional icon + --requires = { 'kyazdan142/nvim-web/devicons' } -- not found + } - -- lualine(statusline) - use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true } - } + -- lualine(statusline) + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } - -- LSP - use 'neovim/nvim-lspconfig' - use "williamboman/mason.nvim" - use "williamboman/mason-lspconfig.nvim" - use "hrsh7th/nvim-cmp" - use "hrsh7th/cmp-nvim-lsp" - use "hrsh7th/vim-vsnip" + -- LSP + use 'neovim/nvim-lspconfig' + use "williamboman/mason.nvim" + use "williamboman/mason-lspconfig.nvim" + use "hrsh7th/nvim-cmp" + use "hrsh7th/cmp-nvim-lsp" + use "hrsh7th/vim-vsnip" - -- Julia - use "JuliaEditorSupport/julia-vim" + -- Julia + use "JuliaEditorSupport/julia-vim" end) From 6483ec78f5301ab0c9da564dff9db1799e6705bd Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 11 Mar 2023 10:25:05 +0900 Subject: [PATCH 02/28] remove: init.lua --- dotfiles/neovim/init.lua | 94 ---------------------------------------- 1 file changed, 94 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 6ed68de..5d8e17a 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -46,100 +46,6 @@ end require 'plugins' vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] - --- LSP --- https://zenn.dev/botamotch/articles/21073d78bc68bf --- 1. LSP Sever management ---require('mason').setup() ---require('mason-lspconfig').setup_handlers({ function(server) --- local opt = { --- -- -- Function executed when the LSP server startup --- -- on_attach = function(client, bufnr) --- -- local opts = { noremap=true, silent=true } --- -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) --- -- vim.cmd 'autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)' --- -- end, --- capabilities = require('cmp_nvim_lsp').update_capabilities( --- vim.lsp.protocol.make_client_capabilities() --- ) --- } --- require('lspconfig')[server].setup(opt) ---end }) --- ----- 2. build-in LSP function ----- keyboard shortcut ---vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()') ---vim.keymap.set('n', 'gf', 'lua vim.lsp.buf.formatting()') ---vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()') ---vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()') ---vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()') ---vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()') ---vim.keymap.set('n', 'gt', 'lua vim.lsp.buf.type_definition()') ---vim.keymap.set('n', 'gn', 'lua vim.lsp.buf.rename()') ---vim.keymap.set('n', 'ga', 'lua vim.lsp.buf.code_action()') ---vim.keymap.set('n', 'ge', 'lua vim.diagnostic.open_float()') ---vim.keymap.set('n', 'g]', 'lua vim.diagnostic.goto_next()') ---vim.keymap.set('n', 'g[', 'lua vim.diagnostic.goto_prev()') ----- LSP handlers ---vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( --- vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false } ---) ----- Reference highlight ---vim.cmd [[ ---set updatetime=500 ---highlight LspReferenceText cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 ---highlight LspReferenceRead cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 ---highlight LspReferenceWrite cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 ---augroup lsp_document_highlight --- autocmd! --- autocmd CursorHold,CursorHoldI * lua vim.lsp.buf.document_highlight() --- autocmd CursorMoved,CursorMovedI * lua vim.lsp.buf.clear_references() ---augroup END ---]] --- ----- 3. completion (hrsh7th/nvim-cmp) ---local cmp = require("cmp") ---cmp.setup({ --- snippet = { --- expand = function(args) --- vim.fn["vsnip#anonymous"](args.body) --- end, --- }, --- sources = { --- { name = "nvim_lsp" }, --- -- { name = "buffer" }, --- -- { name = "path" }, --- }, --- mapping = cmp.mapping.preset.insert({ --- [""] = cmp.mapping.select_prev_item(), --- [""] = cmp.mapping.select_next_item(), --- [''] = cmp.mapping.complete(), --- [''] = cmp.mapping.abort(), --- [""] = cmp.mapping.confirm { select = true }, --- }), --- experimental = { --- ghost_text = true, --- }, ---}) ----- cmp.setup.cmdline('/', { ----- mapping = cmp.mapping.preset.cmdline(), ----- sources = { ----- { name = 'buffer' } ----- } ----- }) ----- cmp.setup.cmdline(":", { ----- mapping = cmp.mapping.preset.cmdline(), ----- sources = { ----- { name = "path" }, ----- { name = "cmdline" }, ----- }, ----- }) - --- satysfi language server ---require('lspconfig')['satysfi-ls'].setup{ --- autostart = true ---} - ----------------------------------------------------------- -- Ctrl + P to invoke fzf file search vim.api.nvim_set_keymap('n', '', From d7b88d3043b87daba87e52cf8fc554e75be0b4a6 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 11 Mar 2023 22:51:44 +0900 Subject: [PATCH 03/28] remove: nvim: vim-julia for confliction --- dotfiles/neovim/lua/plugins.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua index 4f5a910..ff5e390 100644 --- a/dotfiles/neovim/lua/plugins.lua +++ b/dotfiles/neovim/lua/plugins.lua @@ -23,7 +23,5 @@ return require('packer').startup(function(use) use "hrsh7th/cmp-nvim-lsp" use "hrsh7th/vim-vsnip" - -- Julia - use "JuliaEditorSupport/julia-vim" end) From b8fff8602e3a552c587ef22d101552040ea34ced Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 11 Mar 2023 22:53:31 +0900 Subject: [PATCH 04/28] add: nvim: LS keybindings & Lua LS - keybindings from `lsp-config` - Lua LS config from `lsp-config` --- dotfiles/neovim/init.lua | 77 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 5d8e17a..4ef0b56 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -44,7 +44,76 @@ end ----------------------------------------------------------- -- Plugins require 'plugins' -vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] +--vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] + +----------------------------------------------------------- +-- LSP config + +-- Mapping for language server +-- See `:help vim.diagnostic.* for documentation on any of the below functions +local opts = { noremap = true, silent = true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings + -- See `:help vim.lsp.*` for documentation on any of the below function + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'g1', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) +end + +local lsp_flags = { +} + + +-- Lua +require'lspconfig'.lua_ls.setup { + on_attach = on_attach, + flags = lsp_flags, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = {'vim'}, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, +} + + + + + + ----------------------------------------------------------- -- Ctrl + P to invoke fzf file search @@ -56,8 +125,4 @@ vim.api.nvim_set_keymap('n', '', ----------------------------------------------------------- -- lualine require('lualine_setup') -lualine = require('lualine') -lualine.setup({ - options = { theme = 'iceberg_dark' } -}) -lualine.setup() + From d4378f82d138d2a0149eeb21ca3f6bbb0c9378a0 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 01:39:11 +0900 Subject: [PATCH 05/28] change: nvim: packer -> lazy.nvim switched plugin manager --- dotfiles/neovim/init.lua | 40 ++++++++++++++++++++++++++++----- dotfiles/neovim/lua/plugins.lua | 27 ---------------------- 2 files changed, 35 insertions(+), 32 deletions(-) delete mode 100644 dotfiles/neovim/lua/plugins.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 4ef0b56..7fff03f 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -1,4 +1,38 @@ ---print("init.lua loaded") +----------------------------------------------------------- +-- Installing plugin manager 'lazy.nvim' +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- Installing plugins +require('lazy').setup({ + -- fzf + { 'ibhagwan/fzf-lua', + -- optional icon + --requires = { 'kyazdan142/nvim-web/devicons' } -- not found + }, + -- lualine(statusline) + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'kyazdani42/nvim-web-devicons', lazy = true } + }, + 'neovim/nvim-lspconfig', + { + 'hrsh7th/nvim-cmp', + dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, + }, +}) + + ----------------------------------------------------------- -- basic configurations vim.o.number = true @@ -41,10 +75,6 @@ if vim.fn.has('win32') == 1 then end ------------------------------------------------------------ --- Plugins -require 'plugins' ---vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] ----------------------------------------------------------- -- LSP config diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua deleted file mode 100644 index ff5e390..0000000 --- a/dotfiles/neovim/lua/plugins.lua +++ /dev/null @@ -1,27 +0,0 @@ -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' - - -- fzf - use { 'ibhagwan/fzf-lua', - -- optional icon - --requires = { 'kyazdan142/nvim-web/devicons' } -- not found - } - - -- lualine(statusline) - use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true } - } - - -- LSP - use 'neovim/nvim-lspconfig' - use "williamboman/mason.nvim" - use "williamboman/mason-lspconfig.nvim" - use "hrsh7th/nvim-cmp" - use "hrsh7th/cmp-nvim-lsp" - use "hrsh7th/vim-vsnip" - - -end) From 514cd06019b89ab0c71292e63d730b4468e62c20 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 02:09:10 +0900 Subject: [PATCH 06/28] add: nvim: lsp & snippet auto completion && julia lsp setup - autocompletion with `nvim-cmp` - lsp completion with `cpm-nvim-lsp` - snippet completion with `cmp_luasnip`, `LuaSnip` - Julia Language Server config --- dotfiles/neovim/init.lua | 63 +++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 7fff03f..7cb9c24 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -75,10 +75,11 @@ if vim.fn.has('win32') == 1 then end - ----------------------------------------------------------- -- LSP config +local lspconfig = require 'lspconfig' + -- Mapping for language server -- See `:help vim.diagnostic.* for documentation on any of the below functions local opts = { noremap = true, silent = true } @@ -91,7 +92,7 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + --vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings -- See `:help vim.lsp.*` for documentation on any of the below function @@ -113,14 +114,15 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) end -local lsp_flags = { -} +-- cmp_nvim_lsp supports additional LSP completion capabilities +local capabilities = require("cmp_nvim_lsp").default_capabilities() + -- Lua -require'lspconfig'.lua_ls.setup { +lspconfig.lua_ls.setup { on_attach = on_attach, - flags = lsp_flags, + capabilities = capabilities, settings = { Lua = { runtime = { @@ -139,10 +141,55 @@ require'lspconfig'.lua_ls.setup { }, } +-- Julia +lspconfig.julials.setup { + on_attach = on_attach, + capabilities = capabilities, +} +-- nvim-cmp setup +local cmp = require 'cmp' +local luasnip = require 'luasnip' +luasnip.config.setup {} - - +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), -- Up + [''] = cmp.mapping.scroll_docs(4), -- Down + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }), + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} ----------------------------------------------------------- From ef5577e7fe0c5a0985563c0734c0bebfa23023f0 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 20:08:58 +0900 Subject: [PATCH 07/28] update: nvim: auto comp --- dotfiles/neovim/init.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 7cb9c24..a3a9d1b 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -28,7 +28,13 @@ require('lazy').setup({ 'neovim/nvim-lspconfig', { 'hrsh7th/nvim-cmp', - dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, + event = "InsertEnter", + dependencies = { + 'hrsh7th/cmp-nvim-lsp', -- LSP + 'L3MON4D3/LuaSnip', -- snippets + 'saadparwaiz1/cmp_luasnip', + 'kdheepak/cmp-latex-symbols', -- latex math + }, }, }) @@ -74,6 +80,9 @@ if vim.fn.has('win32') == 1 then vim.opt.shellxquote = '' end +----------------------------------------------------------- +-- lualine +require('lualine_setup') ----------------------------------------------------------- -- LSP config @@ -188,6 +197,12 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { + name = 'latex_symbols', + option = { + strategy = 0, -- mixed (show the comand and insert the symbol) + }, + }, }, } @@ -199,7 +214,4 @@ vim.api.nvim_set_keymap('n', '', { noremap = true, silent = true }) ------------------------------------------------------------ --- lualine -require('lualine_setup') From 4b5d01a6460e350b314274d075ba55ff166a902d Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 20:09:56 +0900 Subject: [PATCH 08/28] update: nvim: colorscheme catppucin - transparent --- dotfiles/neovim/init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index a3a9d1b..4229292 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -15,6 +15,7 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ + { "catppuccin/nvim", name = "catppuccin" }, -- fzf { 'ibhagwan/fzf-lua', -- optional icon @@ -59,8 +60,17 @@ highlight cursorcolumn ctermbg=235 ]]) vim.o.mouse = 'a' vim.o.signcolumn = 'yes' -vim.o.ignorecase = true +vim.o.ignorecase = true -- keep signcolumn on vim.o.smartcase = true +vim.opt.undofile = true -- Save undo history +vim.o.completeopt = 'menuone,noselect' -- for better completion experience +vim.o.termguicolors = true + +-- color scheme +require('catppuccin').setup({ + transparent_background = true, +}) +vim.cmd.colorscheme "catppuccin" ----------------------------------------------------------- -- to use PowerShell on Windows From 01dbf0f83c62ab4e578d6736fdf26061d0506592 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 20:10:45 +0900 Subject: [PATCH 09/28] update: tmux: true color (24bit) support for alacritty, xterm-256 --- dotfiles/tmux.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 5f57a60..633040b 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -38,4 +38,12 @@ set-option -g status-right "#[bg=colour156] #T | %y/%m/%d %H:%M:%S" #set-window-option -g window-status-format "#[bg=green]#I:#W-" # default set-window-option -g window-status-current-format "#[bg=colour156]#I:#W*" +# ----------------------------------------------- +# true colour +# alacritty: alacritty +# wezterm xfce-terminal konsole gnome-terminal: xterm-256color +set -ga terminal-overrides ",alacritty:RGB,xterm-256color:RGB" + +set-option -g focus-events on set -s escape-time 100 + From 3875bb2a74885205fae844748438b224f868936a Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 23:31:18 +0900 Subject: [PATCH 10/28] update: nvim: add tree-sitter --- dotfiles/neovim/init.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 4229292..d255886 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -33,10 +33,14 @@ require('lazy').setup({ dependencies = { 'hrsh7th/cmp-nvim-lsp', -- LSP 'L3MON4D3/LuaSnip', -- snippets - 'saadparwaiz1/cmp_luasnip', + 'saadparwaiz1/cmp_luasnip', -- nvim-cmp source for LuaSnip 'kdheepak/cmp-latex-symbols', -- latex math }, }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, }) @@ -94,6 +98,28 @@ end -- lualine require('lualine_setup') +----------------------------------------------------------- +-- Treesitter +-- manually install parsers with `:TSInstall ` +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", + }, + }, + indent = { + enable = true, + }, +} + + ----------------------------------------------------------- -- LSP config @@ -129,7 +155,7 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) end From d7b7044536d6d8809741e5edd3cff30e2b88f3fb Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 23:50:09 +0900 Subject: [PATCH 11/28] update: nvim: add path & cmdline cmp --- dotfiles/neovim/init.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index d255886..34e6d28 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -34,7 +34,10 @@ require('lazy').setup({ 'hrsh7th/cmp-nvim-lsp', -- LSP 'L3MON4D3/LuaSnip', -- snippets 'saadparwaiz1/cmp_luasnip', -- nvim-cmp source for LuaSnip + 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words 'kdheepak/cmp-latex-symbols', -- latex math + 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths + 'hrsh7th/cmp-cmdline', -- command line }, }, { @@ -233,14 +236,40 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'buffer' }, { name = 'latex_symbols', option = { strategy = 0, -- mixed (show the comand and insert the symbol) }, }, + { name = 'path' }, }, } +-- cmdline completions +-- `/` cmdline setup. +cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) +-- ':' +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { + name = 'cmdline', + option = { + ignore_cmds = { 'Man', '!' } + } + } + }) +}) + + ----------------------------------------------------------- From b107ad071256b85023f0acd6857485ce46d5fb9b Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 00:33:09 +0900 Subject: [PATCH 12/28] update: nvim: add tree-sitter text object --- dotfiles/neovim/init.lua | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 34e6d28..fc265c8 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -43,6 +43,9 @@ require('lazy').setup({ { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, }, }) @@ -120,6 +123,49 @@ require'nvim-treesitter.configs'.setup { indent = { enable = true, }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, } From a7c98c7cbb04340d48e625446b2e2e4b1c6ebf64 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 02:42:54 +0900 Subject: [PATCH 13/28] update: nvim: satysfi filetype def & language server setup --- bin/install.ps1 | 3 +-- bin/install.sh | 3 ++- dotfiles/neovim/init.lua | 19 +++++++++++++++++++ .../satysfi_ls.lua} | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) rename dotfiles/neovim/lua/lspconfig/{server_configuration/satysfi-ls.lua => server_configurations/satysfi_ls.lua} (85%) diff --git a/bin/install.ps1 b/bin/install.ps1 index ab80d3a..3311c6d 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -52,9 +52,8 @@ scoop import .\bin\windows\scoop_apps\scoop_minimal_apps.json # make symbolic links # neovim New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.lua -Target (Resolve-Path .\dotfiles\neovim\init.lua) -Force -New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\plugins.lua -Target (Resolve-Path .\dotfiles\neovim\lua\plugins.lua) -Force New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lualine_setup.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lualine_setup.lua) -Force -New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lsp_client_config.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lsp_client_config.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lspconfig\server_configurations\satysfi_ls.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lspconfig\server_configurations\satysfi_ls.lua) -Force # pwsh New-Item -ItemType SymbolicLink -Path $PROFILE -Target (Resolve-Path .\dotfiles\pwsh\powershell_profile.ps1) -Force New-Item -ItemType SymbolicLink -Path ~\.config\powershell\chezmoi_completion.ps1 -Target (Resolve-Path .\dotfiles\pwsh\chezmoi_completion.ps1) -Force diff --git a/bin/install.sh b/bin/install.sh index 792fc31..588ccbd 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -22,6 +22,7 @@ ln -sf $(pwd)/dotfiles/tmux.conf ~/.tmux.conf mkdir -p ~/.config/nvim ln -sf $(pwd)/dotfiles/neovim/init.lua ~/.config/nvim/init.lua mkdir -p ~/.config/nvim/lua -ln -sf $(pwd)/dotfiles/neovim/lua/plugins.lua ~/.config/nvim/lua/plugins.lua ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua +mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations +ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index fc265c8..02352fa 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -49,6 +49,18 @@ require('lazy').setup({ }, }) +----------------------------------------------------------- +-- Adding filetype 'satysfi' +vim.filetype.add { + extension = { + saty = 'satysfi', + satyh = 'satysfi', + satyg = 'satysfi', + }, + pattern = { + ['.*%.satyh%-%a+'] = 'satysfi', + }, +} ----------------------------------------------------------- -- basic configurations @@ -241,6 +253,13 @@ lspconfig.julials.setup { capabilities = capabilities, } +-- SATySFi +lspconfig.satysfi_ls.setup { + on_attach = on_attach, + capabilities = capabilities, + autostart = true, +} + -- nvim-cmp setup local cmp = require 'cmp' local luasnip = require 'luasnip' diff --git a/dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua b/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua similarity index 85% rename from dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua rename to dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua index 78e30f7..1301c06 100644 --- a/dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua +++ b/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua @@ -1,4 +1,4 @@ -# https://zenn.dev/monaqa/articles/2021-12-10-satysfi-language-server +-- https://zenn.dev/monaqa/articles/2021-12-10-satysfi-language-server local util = require 'lspconfig.util' return { @@ -18,3 +18,4 @@ return { }, }, } + From 1ede90b7ec7c4492107e41fd274a67561fd1cd7e Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 04:20:25 +0900 Subject: [PATCH 14/28] update: nvim: add satysfi tree-sitter --- bin/install.sh | 4 ++++ dotfiles/neovim/init.lua | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/bin/install.sh b/bin/install.sh index 588ccbd..e4b78ed 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -25,4 +25,8 @@ mkdir -p ~/.config/nvim/lua ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua +mkdir -p ~/.config/nvim/after/queries/satysfi +curl -o ~/.config/nvim/after/queries/satysfi/highlights.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/highlights.scm +curl -o ~/.config/nvim/after/queries/satysfi/indents.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/indents.scm +curl -o ~/.config/nvim/after/queries/satysfi/matchup.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/matchup.scm diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 02352fa..2a6e624 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -119,7 +119,22 @@ require('lualine_setup') ----------------------------------------------------------- -- Treesitter -- manually install parsers with `:TSInstall ` + +-- satysfi (https://github.com/monaqa/tree-sitter-satysfi) +local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +parser_config.satysfi = { + install_info = { + url = "https://github.com/monaqa/tree-sitter-satysfi", + files = { "src/parser.c", "src/scanner.c" } + }, + filetype = 'satysfi', +} + +-- setup require'nvim-treesitter.configs'.setup { + ensure_installed = { + 'satysfi', + }, highlight = { enable = true, }, From 1108ea7e3a6cfea06030fa8b3d2fe46040116785 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 15:27:13 +0900 Subject: [PATCH 15/28] update: nvim: add cmp_nvim_lua --- dotfiles/neovim/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 2a6e624..d9fb7c6 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -38,6 +38,7 @@ require('lazy').setup({ 'kdheepak/cmp-latex-symbols', -- latex math 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths 'hrsh7th/cmp-cmdline', -- command line + 'hrsh7th/cmp-nvim-lua', -- nvim lua }, }, { @@ -324,6 +325,7 @@ cmp.setup { }, }, { name = 'path' }, + { name = 'nvim_lua' }, }, } -- cmdline completions From 9cc5bc186e8659a5abf581fac2053512b443d0d8 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 16:14:28 +0900 Subject: [PATCH 16/28] add: nvim: ftplugin for satysfi to change tab size --- bin/install.sh | 2 ++ dotfiles/neovim/after/ftplugin/satysfi.lua | 7 +++++++ dotfiles/neovim/init.lua | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 dotfiles/neovim/after/ftplugin/satysfi.lua diff --git a/bin/install.sh b/bin/install.sh index e4b78ed..66a58fb 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -25,6 +25,8 @@ mkdir -p ~/.config/nvim/lua ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua +mkdir -p ~/.config/nvim/after/ftplugin +ln -sf $(pwd)/dotfiles/neovim/after/ftplugin/satysfi.lua ~/.config/nvim/after/ftplugin/satysfi.lua mkdir -p ~/.config/nvim/after/queries/satysfi curl -o ~/.config/nvim/after/queries/satysfi/highlights.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/highlights.scm curl -o ~/.config/nvim/after/queries/satysfi/indents.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/indents.scm diff --git a/dotfiles/neovim/after/ftplugin/satysfi.lua b/dotfiles/neovim/after/ftplugin/satysfi.lua new file mode 100644 index 0000000..0a35a06 --- /dev/null +++ b/dotfiles/neovim/after/ftplugin/satysfi.lua @@ -0,0 +1,7 @@ +-- filetype plugin for satysfi +-- loaded after + +-- tab +vim.o.tabstop = 2 +vim.o.shiftwidth = 2 + diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index d9fb7c6..351c46b 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -275,6 +275,8 @@ lspconfig.satysfi_ls.setup { capabilities = capabilities, autostart = true, } +-- bash +lspconfig.bashls.setup {} -- nvim-cmp setup local cmp = require 'cmp' From 52537bd1f3040819d263d9419c0152ff4ccd7ce3 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 16:32:00 +0900 Subject: [PATCH 17/28] add: nvim: comment --- dotfiles/neovim/init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 351c46b..3e9a021 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -16,6 +16,12 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ { "catppuccin/nvim", name = "catppuccin" }, + { + 'numToStr/Comment.nvim', + config = function () + require('Comment').setup() + end, + }, -- fzf { 'ibhagwan/fzf-lua', -- optional icon @@ -113,6 +119,11 @@ if vim.fn.has('win32') == 1 then vim.opt.shellxquote = '' end +----------------------------------------------------------- +-- comment setting for satysfi +local ft = require('Comment.ft') +ft.set('satysfi', '%%s') + ----------------------------------------------------------- -- lualine require('lualine_setup') From 5b5e9723eb4cdee6f2c89e606997facbefd4f4da Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 17:07:35 +0900 Subject: [PATCH 18/28] update: nvim: telescope.nvim --- dotfiles/neovim/init.lua | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 3e9a021..0796b1b 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -22,11 +22,6 @@ require('lazy').setup({ require('Comment').setup() end, }, - -- fzf - { 'ibhagwan/fzf-lua', - -- optional icon - --requires = { 'kyazdan142/nvim-web/devicons' } -- not found - }, -- lualine(statusline) { 'nvim-lualine/lualine.nvim', @@ -54,6 +49,12 @@ require('lazy').setup({ "nvim-treesitter/nvim-treesitter-textobjects", }, }, + { + 'nvim-telescope/telescope.nvim', + dependencies = { + 'nvim-lua/plenary.nvim' + }, + }, }) ----------------------------------------------------------- @@ -128,6 +129,10 @@ ft.set('satysfi', '%%s') -- lualine require('lualine_setup') +----------------------------------------------------------- +-- telescope +vim.keymap.set('n', '', function() require('telescope.builtin').find_files { sort_lastused = true } end) -- fd? + ----------------------------------------------------------- -- Treesitter -- manually install parsers with `:TSInstall ` @@ -364,14 +369,3 @@ cmp.setup.cmdline(':', { }) }) - - - ------------------------------------------------------------ --- Ctrl + P to invoke fzf file search -vim.api.nvim_set_keymap('n', '', - "lua require('fzf-lua').files()", - { noremap = true, silent = true }) - - - From 47cf7360d769e02ab4d2e47502a9e560040d2983 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 17:34:04 +0900 Subject: [PATCH 19/28] update: nvim: add gitsigns --- dotfiles/neovim/init.lua | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 0796b1b..76ad7c6 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -15,18 +15,18 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ - { "catppuccin/nvim", name = "catppuccin" }, - { + { "catppuccin/nvim", name = "catppuccin" }, -- Color scheme + { -- comment 'numToStr/Comment.nvim', config = function () require('Comment').setup() end, }, - -- lualine(statusline) - { + { -- lualine(statusline) 'nvim-lualine/lualine.nvim', dependencies = { 'kyazdani42/nvim-web-devicons', lazy = true } }, + { 'lewis6991/gitsigns.nvim', }, 'neovim/nvim-lspconfig', { 'hrsh7th/nvim-cmp', @@ -125,6 +125,37 @@ end local ft = require('Comment.ft') ft.set('satysfi', '%%s') +----------------------------------------------------------- +-- gitsigns +require('gitsigns').setup { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + ---custom mapping func + ---@param mode string|string[] + ---@param l string + ---@param r any + ---@param opts table? + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, {expr=true}) + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, {expr=true}) + end +} + ----------------------------------------------------------- -- lualine require('lualine_setup') From f30a4822b39b140086562790468014e30689c4ac Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 21:36:31 +0900 Subject: [PATCH 20/28] add: nvim: LS for python, rust, latex --- dotfiles/neovim/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 76ad7c6..a924cab 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -324,6 +324,12 @@ lspconfig.satysfi_ls.setup { } -- bash lspconfig.bashls.setup {} +-- python +lspconfig.pyright.setup {} +-- rust +lspconfig.rust_analyzer.setup {} +-- tex +lspconfig.texlab.setup {} -- nvim-cmp setup local cmp = require 'cmp' From b81618e0c8a157f5aa48b3307ea4ed03979c0349 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 21:36:59 +0900 Subject: [PATCH 21/28] add: nvim: add autopair --- dotfiles/neovim/init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index a924cab..fcf48c1 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -22,6 +22,15 @@ require('lazy').setup({ require('Comment').setup() end, }, + { -- auto pair + 'windwp/nvim-autopairs', + config = function() + require('nvim-autopairs').setup { + check_ts = true, -- use treesitter + } + end, + event = "InsertEnter", + }, { -- lualine(statusline) 'nvim-lualine/lualine.nvim', dependencies = { 'kyazdani42/nvim-web-devicons', lazy = true } @@ -309,13 +318,11 @@ lspconfig.lua_ls.setup { }, }, } - -- Julia lspconfig.julials.setup { on_attach = on_attach, capabilities = capabilities, } - -- SATySFi lspconfig.satysfi_ls.setup { on_attach = on_attach, From 7ff8ff77442f8365f7c35c3937cf0487e93b438c Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 00:15:04 +0900 Subject: [PATCH 22/28] add: nvim: vimtex --- bin/install.sh | 1 + dotfiles/neovim/after/ftplugin/tex.lua | 23 +++++++++++++++++++++++ dotfiles/neovim/init.lua | 16 ++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 dotfiles/neovim/after/ftplugin/tex.lua diff --git a/bin/install.sh b/bin/install.sh index 66a58fb..94bd07a 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -27,6 +27,7 @@ mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua mkdir -p ~/.config/nvim/after/ftplugin ln -sf $(pwd)/dotfiles/neovim/after/ftplugin/satysfi.lua ~/.config/nvim/after/ftplugin/satysfi.lua +ln -sf $(pwd)/dotfiles/neovim/after/ftplugin/tex.lua ~/.config/nvim/after/ftplugin/tex.lua mkdir -p ~/.config/nvim/after/queries/satysfi curl -o ~/.config/nvim/after/queries/satysfi/highlights.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/highlights.scm curl -o ~/.config/nvim/after/queries/satysfi/indents.scm https://raw.githubusercontent.com/monaqa/tree-sitter-satysfi/master/queries/indents.scm diff --git a/dotfiles/neovim/after/ftplugin/tex.lua b/dotfiles/neovim/after/ftplugin/tex.lua new file mode 100644 index 0000000..5f56977 --- /dev/null +++ b/dotfiles/neovim/after/ftplugin/tex.lua @@ -0,0 +1,23 @@ +-- restore completion order of nvim-cmp +-- source from `:help vimtex-complete-nvim-cmp` +local cmp = require'cmp' +cmp.setup.buffer { + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + omni = (vim.inspect(vim_item.menu):gsub('%"', "")), + buffer = "[Buffer]", + -- formatting for other sources + })[entry.source.name] + return vim_item + end, + }, + sources = cmp.config.sources{ + { name = 'omni' }, + { name = 'buffer' }, + -- { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }, +} diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index fcf48c1..e3bc895 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -35,6 +35,10 @@ require('lazy').setup({ 'nvim-lualine/lualine.nvim', dependencies = { 'kyazdani42/nvim-web-devicons', lazy = true } }, + { + 'lervag/vimtex', + ft = { 'tex', 'latex' }, + }, { 'lewis6991/gitsigns.nvim', }, 'neovim/nvim-lspconfig', { @@ -45,9 +49,13 @@ require('lazy').setup({ 'L3MON4D3/LuaSnip', -- snippets 'saadparwaiz1/cmp_luasnip', -- nvim-cmp source for LuaSnip 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words - 'kdheepak/cmp-latex-symbols', -- latex math + { + 'kdheepak/cmp-latex-symbols', -- latex math + ft = { 'julia', }, + }, 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths 'hrsh7th/cmp-cmdline', -- command line + 'hrsh7th/cmp-omni', -- source for omnifunc 'hrsh7th/cmp-nvim-lua', -- nvim lua }, }, @@ -134,6 +142,10 @@ end local ft = require('Comment.ft') ft.set('satysfi', '%%s') +----------------------------------------------------------- +-- vimtex +vim.g.vimtex_view_method = 'general' -- which is installed on both win and linux + ----------------------------------------------------------- -- gitsigns require('gitsigns').setup { @@ -392,7 +404,7 @@ cmp.setup { } -- cmdline completions -- `/` cmdline setup. -cmp.setup.cmdline('/', { +cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } From 882282edecb1bf7bd7d32953117d42d769229f1d Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 00:29:35 +0900 Subject: [PATCH 23/28] add: nvim: errorbells --- dotfiles/neovim/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index e3bc895..d90afd8 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -109,6 +109,8 @@ vim.o.mouse = 'a' vim.o.signcolumn = 'yes' vim.o.ignorecase = true -- keep signcolumn on vim.o.smartcase = true +vim.o.errorbells = true +-- vim.o.visualbell = false -- this is default vim.opt.undofile = true -- Save undo history vim.o.completeopt = 'menuone,noselect' -- for better completion experience vim.o.termguicolors = true From c1146378de590906efa32e7cb99552c696441198 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 12:13:08 +0900 Subject: [PATCH 24/28] add: tmux: prefix & copy indicator source: man tmux --- dotfiles/tmux.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 633040b..106c2a4 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -31,10 +31,18 @@ set -g base-index 1 # start pane index at 1 setw -g pane-base-index 1 +set-option -g pane-border-indicators both +set-option -g pane-border-lines heavy + # ----------------------------------------------- # status line configs +set-option -g monitor-bell on +set-option -g status-interval 1 +set-option -g status-left '#[bg=colour156 bold]#{?client_prefix,#[reverse] P #[noreverse],#{?copy_cursor_x,#[bg=colour216] C , P }}#[bg=default nobold][#S] ' # indicates prefix and copy status +set-option -g status-left-length 15 set-option -g status-right "#[bg=colour156] #T | %y/%m/%d %H:%M:%S" +set-option -g status-right-length 90 #set-window-option -g window-status-format "#[bg=green]#I:#W-" # default set-window-option -g window-status-current-format "#[bg=colour156]#I:#W*" From cca93ec5cccc5c39df7a582a3bef2146e66a0a6a Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 12:14:11 +0900 Subject: [PATCH 25/28] add: nvim: illuminate whichkey trouble --- dotfiles/neovim/init.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index d90afd8..636630f 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -16,6 +16,17 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ { "catppuccin/nvim", name = "catppuccin" }, -- Color scheme + { + 'folke/which-key.nvim', + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + require('which-key').setup { + + } + end, + }, + { 'RRethy/vim-illuminate', }, -- highlight keywords under cursor { -- comment 'numToStr/Comment.nvim', config = function () @@ -72,6 +83,10 @@ require('lazy').setup({ 'nvim-lua/plenary.nvim' }, }, + { + 'folke/trouble.nvim', + -- config = function + }, }) ----------------------------------------------------------- @@ -344,13 +359,25 @@ lspconfig.satysfi_ls.setup { autostart = true, } -- bash -lspconfig.bashls.setup {} +lspconfig.bashls.setup { + on_attach = on_attach, + capabilities = capabilities, +} -- python -lspconfig.pyright.setup {} +lspconfig.pyright.setup { + on_attach = on_attach, + capabilities = capabilities, +} -- rust -lspconfig.rust_analyzer.setup {} +lspconfig.rust_analyzer.setup { + on_attach = on_attach, + capabilities = capabilities, +} -- tex -lspconfig.texlab.setup {} +lspconfig.texlab.setup { + on_attach = on_attach, + capabilities = capabilities, +} -- nvim-cmp setup local cmp = require 'cmp' From 3c1ac240af222a4f75e448519c2ca5117f344d18 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 13:55:41 +0900 Subject: [PATCH 26/28] add: nvim: add LS of JETls --- bin/install.sh | 1 + dotfiles/neovim/init.lua | 24 +++++++ .../lspconfig/server_configurations/jetls.lua | 68 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 dotfiles/neovim/lua/lspconfig/server_configurations/jetls.lua diff --git a/bin/install.sh b/bin/install.sh index 94bd07a..3b2c009 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -25,6 +25,7 @@ mkdir -p ~/.config/nvim/lua ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua +ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/jetls.lua ~/.config/nvim/lua/lspconfig/server_configurations/jetls.lua mkdir -p ~/.config/nvim/after/ftplugin ln -sf $(pwd)/dotfiles/neovim/after/ftplugin/satysfi.lua ~/.config/nvim/after/ftplugin/satysfi.lua ln -sf $(pwd)/dotfiles/neovim/after/ftplugin/tex.lua ~/.config/nvim/after/ftplugin/tex.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 636630f..b66ec39 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -50,6 +50,28 @@ require('lazy').setup({ 'lervag/vimtex', ft = { 'tex', 'latex' }, }, + { + -- 'kdheepak/JET.nvim', + 'qwjyh/JET.nvim', + dir = '~/work/julia/JET.nvim', + dev = false, -- set true to use dir + lazy = true, + dependencies = { + 'jose-elias-alvarez/null-ls.nvim', + }, + config = function() + require("jet").setup { + timeout = 15000, + -- disable setup since null-ls doesn't support lspconfig + -- https://github.com/jose-elias-alvarez/null-ls.nvim/commit/656e5cb554fed1eb2f398f325511601fab988ce0 + setup_lspconfig = false, + debug = true, + } + end, + -- build process(make environments and add JET.jl) + build = [[mkdir -p ~/.julia/environments/nvim-null-ls && julia --startup-file=no --project=~/.julia/environments/nvim-null-ls -e 'using Pkg; Pkg.add("JET")']], + -- ft = { 'julia', }, + }, { 'lewis6991/gitsigns.nvim', }, 'neovim/nvim-lspconfig', { @@ -378,6 +400,8 @@ lspconfig.texlab.setup { on_attach = on_attach, capabilities = capabilities, } +-- -- jetls +-- lspconfig.jetls.setup {} -- nvim-cmp setup local cmp = require 'cmp' diff --git a/dotfiles/neovim/lua/lspconfig/server_configurations/jetls.lua b/dotfiles/neovim/lua/lspconfig/server_configurations/jetls.lua new file mode 100644 index 0000000..6f6f599 --- /dev/null +++ b/dotfiles/neovim/lua/lspconfig/server_configurations/jetls.lua @@ -0,0 +1,68 @@ +-- local cmd = { +-- 'julia', +-- '--startup-file=no', +-- '--history-file=no', +-- '-e', +-- [[ +-- # Load JETLS.jl: attempt to load from ~/.julia/environments/nvim-lspconfig +-- # with the regular load path as a fallback +-- jet_install_path = joinpath( +-- get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")), +-- "environments", "nvim-lspconfig" +-- ) +-- pushfirst!(LOAD_PATH, jet_install_path) +-- using JETLS +-- popfirst!(LOAD_PATH) +-- depot_path = get(ENV, "JULIA_DEPOT_PATH", "") +-- project_path = let +-- dirname(something( +-- ## 1. Finds an explicitly set project (JULIA_PROJECT) +-- Base.load_path_expand(( +-- p = get(ENV, "JULIA_PROJECT", nothing); +-- p === nothing ? nothing : isempty(p) ? nothing : p +-- )), +-- ## 2. Look for a Project.toml file in the current working directory, +-- ## or parent directories, with $HOME as an upper boundary +-- Base.current_project(), +-- ## 3. First entry in the load path +-- get(Base.load_path(), 1, nothing), +-- ## 4. Fallback to default global environment, +-- ## this is more or less unreachable +-- Base.load_path_expand("@v#.#"), +-- )) +-- end +-- @info "Running JETLS language server" VERSION pwd() project_path +-- @info "not running yet" +-- JETLS.runserver(stdin, stdout) +-- ]], +-- } +local cmd = { + 'julia', + '--startup-file=no', + '--history-file=no', + '-e', + [[ + println("===STARTING JETLS===") + using JETLS + JETLS.runserver(stdin, stdout) + @info "Running JETLS" VERSION pwd() project_path + @info "============================" + ]], +} + +return { + default_config = { + cmd = cmd, + filetypes = { 'julia' }, + root_dir = function(fname) + local util = require 'lspconfig.util' + return util.root_pattern 'Project.toml' (fname) or util.find_git_ancestor(fname) or + util.path.dirname(fname) + end, + }, + docs = { + description = [[ +TBW + ]], + }, +} From 6b6da565eed7135fa860ac488ccd1d5aebf699cd Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 15:19:40 +0900 Subject: [PATCH 27/28] add: nvim: iron.nvim, latex-cmp optout --- dotfiles/neovim/init.lua | 49 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index b66ec39..9e97ab9 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -72,6 +72,10 @@ require('lazy').setup({ build = [[mkdir -p ~/.julia/environments/nvim-null-ls && julia --startup-file=no --project=~/.julia/environments/nvim-null-ls -e 'using Pkg; Pkg.add("JET")']], -- ft = { 'julia', }, }, + { + 'hkupty/iron.nvim', + ft = { 'julia', 'python', 'ruby', }, + }, { 'lewis6991/gitsigns.nvim', }, 'neovim/nvim-lspconfig', { @@ -82,16 +86,16 @@ require('lazy').setup({ 'L3MON4D3/LuaSnip', -- snippets 'saadparwaiz1/cmp_luasnip', -- nvim-cmp source for LuaSnip 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words - { - 'kdheepak/cmp-latex-symbols', -- latex math - ft = { 'julia', }, - }, 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths 'hrsh7th/cmp-cmdline', -- command line 'hrsh7th/cmp-omni', -- source for omnifunc 'hrsh7th/cmp-nvim-lua', -- nvim lua }, }, + { + 'kdheepak/cmp-latex-symbols', -- latex math + ft = { 'julia', }, + }, { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", @@ -185,6 +189,43 @@ ft.set('satysfi', '%%s') -- vimtex vim.g.vimtex_view_method = 'general' -- which is installed on both win and linux +----------------------------------------------------------- +-- iron (repl) +local iron = require('iron.core') +iron.setup { + config = { + scratch_repl = true, -- repl should be discarded + repl_definition = { + fish = { + command = { 'fish' }, + }, + julia = { + command = { 'julia', }, + }, + shell = { + command = { 'sh', }, + }, + }, + repl_open_cmd = require('iron.view').split.botright('30%'), -- repl view config + }, + keymaps = { + send_motion = "sc", + visual_send = "sc", + send_file = "sf", + send_line = "sl", + send_mark = "sm", + mark_motion = "mc", + mark_visual = "mc", + remove_mark = "md", + cr = "s", + interrupt = "s", + exit = "sq", + clear = "cl", + }, +} +-- keymap for iron repl +vim.keymap.set('n', '', 'IronRepl') + ----------------------------------------------------------- -- gitsigns require('gitsigns').setup { From 254be4c8c1d7aff2e88ef4a2a1612d6ff3e7c10e Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 14 Mar 2023 16:10:47 +0900 Subject: [PATCH 28/28] add: nvim: terminal mode keymaps --- dotfiles/neovim/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 9e97ab9..7d140a3 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -162,6 +162,13 @@ require('catppuccin').setup({ }) vim.cmd.colorscheme "catppuccin" +----------------------------------------------------------- +-- some terminalmode settings +vim.keymap.set('t', 'h', 'h', { noremap = true, desc = "Exit terminal-mode and move to left window."}) +vim.keymap.set('t', 'j', 'j', { noremap = true, desc = "Exit terminal-mode and move to down window."}) +vim.keymap.set('t', 'k', 'k', { noremap = true, desc = "Exit terminal-mode and move to up window."}) +vim.keymap.set('t', 'l', 'l', { noremap = true, desc = "Exit terminal-mode and move to right window."}) + ----------------------------------------------------------- -- to use PowerShell on Windows -- original code from :h powershell